wip fix
This commit is contained in:
1 parent
9bcd4432c6
commit
6f92f9e1d5
1209 files changed
+220940
No files matched your search
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\AlarmSetting;
|
||||
use App\Models\MultilineSetting;
|
||||
use Filament\Actions\Concerns\InteractsWithActions;
|
||||
use Filament\Actions\Contracts\HasActions;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
use Filament\Support\Enums\FontWeight;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\TextInputColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Concerns\InteractsWithTable;
|
||||
use Filament\Tables\Contracts\HasTable;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Livewire\Component;
|
||||
|
||||
class AlarmBookmaker extends Component implements HasActions, HasSchemas, HasTable
|
||||
{
|
||||
use InteractsWithActions;
|
||||
use InteractsWithSchemas;
|
||||
use InteractsWithTable;
|
||||
|
||||
protected $listeners = [
|
||||
'refreshAlarmBookmaker' => '$refresh',
|
||||
];
|
||||
|
||||
public static int $default_filter;
|
||||
|
||||
public static function load_filter(int $sport_id)
|
||||
{
|
||||
self::$default_filter = MultilineSetting::where('sport_id', (int) $sport_id)
|
||||
->orderBy('id')->pluck('id')->first();
|
||||
}
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
self::load_filter(auth()->user()->sport_id);
|
||||
|
||||
return $table
|
||||
->query(AlarmSetting::query()
|
||||
->where('client_bookmaker_id', auth()->user()->bookmaker_id)
|
||||
->where('sport_id', auth()->user()->sport_id))
|
||||
->paginated(false)
|
||||
->columns([
|
||||
// IconColumn::make('sport.icon')
|
||||
// ->label('')
|
||||
// ->width('1rem')
|
||||
// ->icon(function ($record): string {
|
||||
// return $record->sport->icon;
|
||||
// })
|
||||
// ->color(fn ($record): string => match ($record->alarm_level_id) {
|
||||
// 1 => 'success',
|
||||
// 2 => 'warning',
|
||||
// 3 => 'danger',
|
||||
// }),
|
||||
// TextColumn::make('sport.name'),
|
||||
TextColumn::make('alarm_level.name')
|
||||
->color(fn($record) => $record->alarm_level->color)
|
||||
->weight(FontWeight::Black),
|
||||
TextInputColumn::make('alarm_threshold')
|
||||
->tooltip('Between 0.01 - 2.00')
|
||||
->width('2rem')
|
||||
->prefix('Threshold:')
|
||||
->rules(['required', 'decimal:2', 'between:0,2']),
|
||||
TextColumn::make('multiline_setting.name')->label('Bettype'),
|
||||
ToggleColumn::make('disabled'),
|
||||
])
|
||||
->defaultSort('alarm_level_id')
|
||||
->deferFilters(false)
|
||||
->filters([
|
||||
Filter::make('multiline_setting_id')
|
||||
->schema([
|
||||
Radio::make('multiline_setting_id')
|
||||
->extraAttributes([
|
||||
'class' => 'radio-monitor-group'
|
||||
])
|
||||
->inline()
|
||||
->columnSpan(6)
|
||||
->default(self::$default_filter)
|
||||
->columnSpanFull()
|
||||
->hiddenLabel()
|
||||
->options(fn() => MultilineSetting::where('sport_id', auth()->user()->sport_id)->orderBy('name')->pluck('name', 'id')),
|
||||
])
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
return $query
|
||||
->when(
|
||||
$data['multiline_setting_id'],
|
||||
fn(Builder $query, $multiline_setting_id): Builder => $query->where('multiline_setting_id', $multiline_setting_id),
|
||||
);
|
||||
})
|
||||
->columns(6)->columnSpan(6),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->hiddenFilterIndicators();
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.alarm-bookmaker');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\BettypeUser;
|
||||
use App\Models\EventBookmaker;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Livewire\Component;
|
||||
|
||||
class BettypeToggle extends Component
|
||||
{
|
||||
public $bettype_toggles = [];
|
||||
|
||||
public $bookmakerCount = 0;
|
||||
|
||||
public $partnerCount = 0;
|
||||
|
||||
public $bookmakerPartnerDiffrences = 0;
|
||||
|
||||
protected $listeners = [
|
||||
'refreshBettypeMenu' => '$refresh',
|
||||
];
|
||||
|
||||
public function boot()
|
||||
{
|
||||
$this->bettype_toggles = [];
|
||||
|
||||
$this->countBookmaker();
|
||||
|
||||
$res = BettypeUser::with('multiline_setting')
|
||||
->where('user_id', auth()->user()->id)
|
||||
->where('sport_id', auth()->user()->sport_id)
|
||||
->orderBy('sorting')
|
||||
->get();
|
||||
|
||||
foreach ($res as $set) {
|
||||
$this->bettype_toggles[] = [
|
||||
'id' => $set->multiline_setting_id,
|
||||
'name' => $set->multiline_setting->name,
|
||||
'short' => $set->multiline_setting->short,
|
||||
'matchpart' => $set->multiline_setting->matchpart,
|
||||
'is_active' => $set->is_active,
|
||||
];
|
||||
}
|
||||
|
||||
// $filters = $livewire->getTable()->getFilters();
|
||||
// $filters = [$filters];
|
||||
// foreach ($filters as $value) {
|
||||
// dd($value['events']->getState());
|
||||
// }
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.bettype-toggle');
|
||||
}
|
||||
|
||||
public function clearAllFilter()
|
||||
{
|
||||
User::where('id', auth()->user()->id)->update([
|
||||
'partner_compare' => 0,
|
||||
'partner_show' => 0,
|
||||
'all_only_none' => 0,
|
||||
'bookmaker_partner_differences' => 0,
|
||||
'starttime_differences' => 0,
|
||||
]);
|
||||
$this->dispatch('refreshBettypeMenu');
|
||||
$this->dispatch('filterClearFilter');
|
||||
$this->dispatch('refreshTable');
|
||||
}
|
||||
|
||||
public function toggleBettype($multiline_setting_id)
|
||||
{
|
||||
BettypeUser::where('multiline_setting_id', $multiline_setting_id)->update(['is_active' => DB::raw('!is_active')]);
|
||||
|
||||
$this->dispatch('refreshBettypeMenu');
|
||||
|
||||
$this->dispatch('refreshTable');
|
||||
}
|
||||
|
||||
public function toggleStar()
|
||||
{
|
||||
$this->dispatch('filterStarFilter');
|
||||
}
|
||||
|
||||
public function toggleNote()
|
||||
{
|
||||
$this->dispatch('filterNoteFilter');
|
||||
}
|
||||
|
||||
public function toggleShowPartner()
|
||||
{
|
||||
User::where('id', auth()->user()->id)->update(['partner_compare' => 0, 'partner_show' => DB::raw('!partner_show')]);
|
||||
|
||||
$this->dispatch('refreshBettypeMenu');
|
||||
|
||||
$this->dispatch('refreshTable');
|
||||
|
||||
}
|
||||
|
||||
public function toggleComparePartner()
|
||||
{
|
||||
User::where('id', auth()->user()->id)->update(['partner_compare' => DB::raw('!partner_compare')]);
|
||||
|
||||
$this->dispatch('refreshBettypeMenu');
|
||||
|
||||
$this->dispatch('refreshTable');
|
||||
}
|
||||
|
||||
public function toggleMultiline()
|
||||
{
|
||||
User::where('id', auth()->user()->id)->update(['is_multiline_direct' => DB::raw('!is_multiline_direct')]);
|
||||
|
||||
$this->dispatch('refreshBettypeMenu');
|
||||
|
||||
$this->dispatch('refreshTable');
|
||||
}
|
||||
|
||||
public function setToday()
|
||||
{
|
||||
$data = [
|
||||
'start' => Carbon::today()->format('Y-m-d 00:00:00'),
|
||||
'end' => Carbon::tomorrow()->format('Y-m-d 00:00:00'),
|
||||
];
|
||||
$this->dispatch('filterUpdatePeriode', json_encode($data));
|
||||
}
|
||||
|
||||
public function setTomorrow()
|
||||
{
|
||||
$data = [
|
||||
'start' => Carbon::tomorrow()->format('Y-m-d 00:00:00'),
|
||||
'end' => Carbon::tomorrow()->addDay()->format('Y-m-d 00:00:00'),
|
||||
];
|
||||
$this->dispatch('filterUpdatePeriode', json_encode($data));
|
||||
}
|
||||
|
||||
public function setOneWeek()
|
||||
{
|
||||
$data = [
|
||||
'start' => Carbon::today()->format('Y-m-d 00:00:00'),
|
||||
'end' => Carbon::today()->addDays(7)->format('Y-m-d 00:00:00'),
|
||||
];
|
||||
$this->dispatch('filterUpdatePeriode', json_encode($data));
|
||||
}
|
||||
|
||||
public function setAllOnlyNone($value)
|
||||
{
|
||||
User::where('id', auth()->user()->id)->update(['all_only_none' => $value]);
|
||||
|
||||
$this->dispatch('refreshBettypeMenu');
|
||||
|
||||
$this->dispatch('refreshTable');
|
||||
}
|
||||
|
||||
public function countBookmaker()
|
||||
{
|
||||
$this->bookmakerCount = EventBookmaker::where('bookmaker_id', auth()->user()->bookmaker_id)
|
||||
->where('starttime', '>', Carbon::now()->timezone('CET'))
|
||||
->where('sport_id', auth()->user()->sport_id)
|
||||
->count();
|
||||
|
||||
$this->partnerCount = EventBookmaker::where('bookmaker_id', auth()->user()->partner_bookmaker_id)
|
||||
->where('starttime', '>', Carbon::now()->timezone('CET'))
|
||||
->where('sport_id', auth()->user()->sport_id)
|
||||
->count();
|
||||
|
||||
$this->bookmakerPartnerDiffrences = DB::table('event_bookmakers')
|
||||
->selectRaw('count(id) as c, event_id')
|
||||
->whereIn('bookmaker_id', [auth()->user()->bookmaker_id, auth()->user()->partner_bookmaker_id])
|
||||
->where('sport_id', auth()->user()->sport_id)
|
||||
->where('starttime', '>', Carbon::now()->timezone('CET'))
|
||||
->groupBy('event_id')
|
||||
->havingRaw('c = 1')
|
||||
->count();
|
||||
}
|
||||
|
||||
public function toggleBookmakerPartnerDifferences()
|
||||
{
|
||||
User::where('id', auth()->user()->id)->update(['bookmaker_partner_differences' => DB::raw('!bookmaker_partner_differences')]);
|
||||
|
||||
$this->dispatch('updateCompareDifferences');
|
||||
|
||||
$this->dispatch('refreshBettypeMenu');
|
||||
|
||||
$this->dispatch('refreshTable');
|
||||
}
|
||||
|
||||
public function filterStarttimeDifferences()
|
||||
{
|
||||
User::where('id', auth()->user()->id)->update(['starttime_differences' => DB::raw('!starttime_differences')]);
|
||||
|
||||
$this->dispatch('refreshBettypeMenu');
|
||||
|
||||
$this->dispatch('refreshTable');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\ClientGroupList;
|
||||
use App\Models\CompetitionGroup;
|
||||
use App\Models\Sport;
|
||||
use Filament\Actions\Concerns\InteractsWithActions;
|
||||
use Filament\Actions\Contracts\HasActions;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Concerns\InteractsWithTable;
|
||||
use Filament\Tables\Contracts\HasTable;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class ClientGroupListEditor extends Component implements HasActions, HasSchemas, HasTable
|
||||
{
|
||||
use InteractsWithActions;
|
||||
use InteractsWithSchemas;
|
||||
use InteractsWithTable;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->query(ClientGroupList::query()->where('sport_id', auth()->user()->sport_id))
|
||||
->description('When creating a group add one league and save, then you can add more leagues to this group.')
|
||||
->columns([
|
||||
TextColumn::make('name'),
|
||||
TextColumn::make('client_groups')
|
||||
->label('Leagues')
|
||||
->badge()
|
||||
->wrap()
|
||||
->color('info')
|
||||
->formatStateUsing(function (string $state): string {
|
||||
$res = CompetitionGroup::with('country')->where('id', $state)->first();
|
||||
|
||||
return $res->country?->name.' '.$res->name;
|
||||
}),
|
||||
])
|
||||
->emptyStateHeading('No Custom Group for '.Sport::where('id', auth()->user()->sport_id)->value('name'))
|
||||
->emptyStateDescription('Create a custom group to get started.')
|
||||
->recordActions([
|
||||
EditAction::make('edit')
|
||||
->iconButton()
|
||||
->mutateDataUsing(function (array $data): array {
|
||||
$data['client_id'] = auth()->user()->client_id;
|
||||
$data['sport_id'] = auth()->user()->sport_id;
|
||||
|
||||
return $data;
|
||||
})
|
||||
->schema([
|
||||
TextInput::make(name: 'name')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Select::make('client_groups')
|
||||
->multiple()
|
||||
->required()
|
||||
->preload()
|
||||
->searchable()
|
||||
->options(function (): array {
|
||||
$res = CompetitionGroup::with('country')->where('sport_id', auth()->user()->sport_id)->orderBy('name')->get();
|
||||
$arr = [];
|
||||
foreach ($res as $value) {
|
||||
$arr[$value->id] = $value->country?->name.' '.$value->name;
|
||||
}
|
||||
asort($arr, SORT_STRING);
|
||||
|
||||
return $arr;
|
||||
|
||||
}),
|
||||
]),
|
||||
DeleteAction::make('delete')->iconButton(),
|
||||
])
|
||||
->headerActions([
|
||||
CreateAction::make()
|
||||
->label('New Group')
|
||||
->schema([
|
||||
TextInput::make(name: 'name')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Select::make('client_groups')
|
||||
->label('League')
|
||||
->searchable()
|
||||
->options(function (): array {
|
||||
$res = CompetitionGroup::with('country')->where('sport_id', auth()->user()->sport_id)->get();
|
||||
$arr = [];
|
||||
foreach ($res as $value) {
|
||||
$arr[$value->id] = $value->country?->name.' '.$value->name;
|
||||
}
|
||||
asort($arr, SORT_STRING);
|
||||
|
||||
return $arr;
|
||||
|
||||
}),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.client-group-list-editor');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Filament\Tables\Columns\BookmakerIcon;
|
||||
use App\Models\ComparingBookmaker;
|
||||
use App\Models\User;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\Concerns\InteractsWithActions;
|
||||
use Filament\Actions\Contracts\HasActions;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\TextInputColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Concerns\InteractsWithTable;
|
||||
use Filament\Tables\Contracts\HasTable;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\TernaryFilter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Support\Collection;
|
||||
use Livewire\Component;
|
||||
|
||||
class ComparingBookmakerMenu extends Component implements HasActions, HasSchemas, HasTable
|
||||
{
|
||||
use InteractsWithActions;
|
||||
use InteractsWithSchemas;
|
||||
use InteractsWithTable;
|
||||
|
||||
public $user;
|
||||
|
||||
protected $listeners = [
|
||||
'refreshComparingBookmakerMenu' => '$refresh',
|
||||
];
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
$this->user = User::getUser();
|
||||
|
||||
return $table
|
||||
->description('')
|
||||
->description('Bookmakers will be compared from top to bottom. First one matches criteria is used for comparition.')
|
||||
->reorderable('sorting')
|
||||
->reorderRecordsTriggerAction(function (Action $action) {
|
||||
return $action->button();
|
||||
})
|
||||
->striped()
|
||||
->query(ComparingBookmaker::query()
|
||||
->with('bookmaker')
|
||||
->where('sport_id', $this->user->sport_id)
|
||||
->where('client_bookmaker_id', $this->user->bookmaker_id)
|
||||
->orderBy('sorting')
|
||||
)
|
||||
->deferLoading()
|
||||
->defaultPaginationPageOption(10)
|
||||
->paginated([5, 10, 15, 30, 50])
|
||||
->extremePaginationLinks()
|
||||
->columns([
|
||||
TextColumn::make('Position')
|
||||
->alignCenter()
|
||||
->badge()
|
||||
->rowIndex(),
|
||||
TextColumn::make('bookmaker_id')->label('Id'),
|
||||
BookmakerIcon::make('bookmaker.icon')->label('Icon')->size('lg'),
|
||||
TextInputColumn::make('time_lastcheck')
|
||||
->label('Time Passed')
|
||||
->prefix('Seconds:')
|
||||
->rules(['required', 'integer', 'between:60,1200']),
|
||||
TextInputColumn::make('margin_threshold')
|
||||
->label('Maximum Margin')
|
||||
->prefix('Threshold:')
|
||||
->rules(['required', 'integer', 'between:100,200']),
|
||||
// ToggleColumn::make('is_active'),
|
||||
])
|
||||
->searchable(['bookmaker_id', 'bookmaker.name'])
|
||||
// ->filters([
|
||||
// TernaryFilter::make('is_active')
|
||||
// ->columnSpan(2)
|
||||
// ->default(1)
|
||||
// ->label('Show active'),
|
||||
// ], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
BulkAction::make('time_lastcheck')
|
||||
->label('Max time since last check in seconds')
|
||||
->icon('phosphor-timer')
|
||||
->action(function (Collection $records, array $data): void {
|
||||
foreach ($records as $record) {
|
||||
ComparingBookmaker::where('id', '=', $record->id)
|
||||
->update(
|
||||
['time_lastcheck' => $data['time_lastcheck']]
|
||||
);
|
||||
}
|
||||
})
|
||||
->schema([
|
||||
|
||||
TextInput::make('time_lastcheck')
|
||||
->numeric()
|
||||
->hiddenLabel()
|
||||
->prefix('Seconds'),
|
||||
]),
|
||||
BulkAction::make('margin_threshold')
|
||||
->label('Maximum height of marging')
|
||||
->icon('phosphor-timer')
|
||||
->action(function (Collection $records, array $data): void {
|
||||
foreach ($records as $record) {
|
||||
ComparingBookmaker::where('id', '=', $record->id)
|
||||
->update(
|
||||
['margin_threshold' => $data['margin_threshold']]
|
||||
);
|
||||
}
|
||||
})
|
||||
->schema([
|
||||
TextInput::make('margin_threshold')
|
||||
->hiddenLabel()
|
||||
->numeric()
|
||||
->minValue(100)
|
||||
->maxValue(250)
|
||||
->prefix('Threshold'),
|
||||
]),
|
||||
BulkAction::make('Switch On')
|
||||
->icon('phosphor-play')
|
||||
->action(function (Collection $records): void {
|
||||
foreach ($records as $record) {
|
||||
ComparingBookmaker::where('id', '=', $record->id)
|
||||
->update(
|
||||
['is_active' => 1]
|
||||
);
|
||||
}
|
||||
}),
|
||||
BulkAction::make('Switch Off')
|
||||
->icon('phosphor-stop')
|
||||
->action(function (Collection $records): void {
|
||||
foreach ($records as $record) {
|
||||
ComparingBookmaker::where('id', '=', $record->id)
|
||||
->update(
|
||||
['is_active' => 0]
|
||||
);
|
||||
}
|
||||
}),
|
||||
]),
|
||||
])->recordActions([
|
||||
Action::make('end')
|
||||
->iconButton()
|
||||
->icon('phosphor-arrow-fat-line-down')
|
||||
->tooltip('Move to the end')
|
||||
->action(function ($record) {
|
||||
$res = ComparingBookmaker::where('method_id', $record->method_id)
|
||||
->where('sport_id', $record->sport_id)
|
||||
->where('client_bookmaker_id', $record->client_bookmaker_id)
|
||||
->orderBy('sorting')
|
||||
->pluck('bookmaker_id', 'id');
|
||||
$sorting = 1;
|
||||
foreach ($res as $id => $bookmaker_id) {
|
||||
if ($bookmaker_id == $record->bookmaker_id) {
|
||||
ComparingBookmaker::where('id', $id)
|
||||
->update(['sorting' => \count($res)]);
|
||||
} else {
|
||||
ComparingBookmaker::where('id', $id)
|
||||
->update(['sorting' => $sorting]);
|
||||
$sorting++;
|
||||
}
|
||||
}
|
||||
}),
|
||||
Action::make('start')
|
||||
->iconButton()
|
||||
->icon('phosphor-arrow-fat-line-up')
|
||||
->tooltip('Move to begining')
|
||||
->action(function ($record) {
|
||||
$res = ComparingBookmaker::where('method_id', $record->method_id)
|
||||
->where('sport_id', $record->sport_id)
|
||||
->where('client_bookmaker_id', $record->client_bookmaker_id)
|
||||
->orderBy('sorting')
|
||||
->pluck('bookmaker_id', 'id');
|
||||
$sorting = 2;
|
||||
foreach ($res as $id => $bookmaker_id) {
|
||||
if ($bookmaker_id == $record->bookmaker_id) {
|
||||
ComparingBookmaker::where('id', $id)
|
||||
->update(['sorting' => 1]);
|
||||
} else {
|
||||
ComparingBookmaker::where('id', $id)
|
||||
->update(['sorting' => $sorting]);
|
||||
$sorting++;
|
||||
}
|
||||
}
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.comparing-bookmaker-menu');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use Filament\Infolists\Components\RepeatableEntry;
|
||||
use Filament\Infolists\Components\RepeatableEntry\TableColumn;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\FontWeight;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Livewire\Attributes\Lazy;
|
||||
use Livewire\Component;
|
||||
|
||||
#[Lazy]
|
||||
class EncounterHistory extends Component implements HasSchemas
|
||||
{
|
||||
use InteractsWithSchemas;
|
||||
|
||||
public $data = [];
|
||||
|
||||
public $betsapi_id;
|
||||
|
||||
public $home;
|
||||
|
||||
public $away;
|
||||
|
||||
public function eventsInfolist(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->record($this->getData())
|
||||
->components([
|
||||
Tabs::make('Tabs')
|
||||
->tabs([
|
||||
Tab::make($this->home.' vs '.$this->away)
|
||||
->badge(fn ($record) => count($record['results']['h2h']))
|
||||
->schema([
|
||||
RepeatableEntry::make('results.h2h')
|
||||
->hiddenLabel()
|
||||
->table([
|
||||
TableColumn::make('League'),
|
||||
TableColumn::make('Date'),
|
||||
TableColumn::make('Home'),
|
||||
TableColumn::make('Away'),
|
||||
TableColumn::make('Result')->alignCenter(),
|
||||
])
|
||||
->schema([
|
||||
TextEntry::make('league.name'),
|
||||
TextEntry::make('time')->formatStateUsing(function ($state) {
|
||||
return Carbon::createFromTimestamp($state)->format('d. m. Y H:i');
|
||||
}),
|
||||
TextEntry::make('home.name')->color(fn (string $state): string => match ($state) {
|
||||
$this->home => 'primary',
|
||||
$this->away => 'warning',
|
||||
default => 'gray',
|
||||
}),
|
||||
TextEntry::make('away.name')->color(fn (string $state): string => match ($state) {
|
||||
$this->home => 'primary',
|
||||
$this->away => 'warning',
|
||||
default => 'gray',
|
||||
}),
|
||||
TextEntry::make('ss')->alignCenter()->weight(FontWeight::Bold),
|
||||
]),
|
||||
]),
|
||||
Tab::make($this->home)
|
||||
->badge(fn ($record) => count($record['results']['home']))
|
||||
->schema([
|
||||
RepeatableEntry::make('results.home')
|
||||
->hiddenLabel()
|
||||
->table([
|
||||
TableColumn::make('League'),
|
||||
TableColumn::make('Date'),
|
||||
TableColumn::make('Home'),
|
||||
TableColumn::make('Away'),
|
||||
TableColumn::make('Result')->alignCenter(),
|
||||
])
|
||||
->schema([
|
||||
TextEntry::make('league.name'),
|
||||
TextEntry::make('time')->formatStateUsing(function ($state) {
|
||||
return Carbon::createFromTimestamp($state)->format('d. m. Y H:i');
|
||||
}),
|
||||
TextEntry::make('home.name')->color(fn (string $state): string => match ($state) {
|
||||
$this->home => 'primary',
|
||||
$this->away => 'warning',
|
||||
default => 'gray',
|
||||
}),
|
||||
TextEntry::make('away.name')->color(fn (string $state): string => match ($state) {
|
||||
$this->home => 'primary',
|
||||
$this->away => 'warning',
|
||||
default => 'gray',
|
||||
}),
|
||||
TextEntry::make('ss')->alignCenter()->weight(FontWeight::Bold),
|
||||
]),
|
||||
]),
|
||||
Tab::make($this->away)
|
||||
->badge(fn ($record) => count($record['results']['away']))
|
||||
->schema([
|
||||
RepeatableEntry::make('results.away')
|
||||
->hiddenLabel()
|
||||
->table([
|
||||
TableColumn::make('League'),
|
||||
TableColumn::make('Date'),
|
||||
TableColumn::make('Home'),
|
||||
TableColumn::make('Away'),
|
||||
TableColumn::make('Result')->alignCenter(),
|
||||
])
|
||||
->schema([
|
||||
TextEntry::make('league.name'),
|
||||
TextEntry::make('time')->formatStateUsing(function ($state) {
|
||||
return Carbon::createFromTimestamp($state)->format('d. m. Y H:i');
|
||||
}),
|
||||
TextEntry::make('home.name')->color(fn (string $state): string => match ($state) {
|
||||
$this->home => 'primary',
|
||||
$this->away => 'warning',
|
||||
default => 'gray',
|
||||
}),
|
||||
TextEntry::make('away.name')->color(fn (string $state): string => match ($state) {
|
||||
$this->home => 'primary',
|
||||
$this->away => 'warning',
|
||||
default => 'gray',
|
||||
}),
|
||||
TextEntry::make('ss')->alignCenter()->weight(FontWeight::Bold),
|
||||
]),
|
||||
]),
|
||||
])->contained(false),
|
||||
]);
|
||||
}
|
||||
|
||||
public function mount($betsapi_id, $home, $away)
|
||||
{
|
||||
$this->betsapi_id = $betsapi_id;
|
||||
$this->home = $home;
|
||||
$this->away = $away;
|
||||
}
|
||||
|
||||
public function getHome()
|
||||
{
|
||||
return $this->home;
|
||||
}
|
||||
|
||||
public function getAway()
|
||||
{
|
||||
return $this->away;
|
||||
}
|
||||
|
||||
public function getData()
|
||||
{
|
||||
return Http::get('https://api.b365api.com/v1/event/history?token='.config('env.betsapi_token').'&event_id='.$this->betsapi_id)->json();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\Client;
|
||||
use App\Models\User;
|
||||
use Livewire\Component;
|
||||
|
||||
class KontoSwitcher extends Component
|
||||
{
|
||||
public $clients = [];
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->clients = Client::where('id', '!=', auth()->user()->client_id)->pluck('name', 'id')->all();
|
||||
}
|
||||
|
||||
public function swopClient($client_id)
|
||||
{
|
||||
$providers = Client::where('id', $client_id)->pluck('provider')->first();
|
||||
|
||||
$provider_id = array_shift($providers);
|
||||
|
||||
$bookmakers = Client::where('id', $client_id)->pluck('bookmaker')->first();
|
||||
|
||||
$bookmaker_id = array_shift($bookmakers);
|
||||
$partner_bookmaker_id = array_shift($bookmakers) ?? 0;
|
||||
|
||||
User::where('id', auth()->user()->id)->update([
|
||||
'sport_id' => 1,
|
||||
'provider_id' => $provider_id,
|
||||
'bookmaker_id' => $bookmaker_id,
|
||||
'partner_bookmaker_id' => $partner_bookmaker_id,
|
||||
'client_id' => $client_id,
|
||||
]);
|
||||
|
||||
$this->js('window.location.reload()');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.konto-switcher');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Mapper;
|
||||
|
||||
use App\Models\Event;
|
||||
use App\Models\Mapper;
|
||||
use App\Models\Element;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class LoadEvents
|
||||
{
|
||||
public static function load($search_values)
|
||||
{
|
||||
$res = Event::query()->where('betradar_id', '>', 0)->pluck('betradar_id');
|
||||
|
||||
foreach ($res as $betradar_id) {
|
||||
Mapper::where('betradar_id', $betradar_id)->delete();
|
||||
}
|
||||
|
||||
if ($search_values) {
|
||||
$element_ids = Element::where(function ($query) use ($search_values) {
|
||||
foreach ($search_values as $value) {
|
||||
$query->orWhere('name', 'LIKE', '%' . $value . '%');
|
||||
}
|
||||
})->pluck('id')->toArray();
|
||||
|
||||
$query = Event::query()
|
||||
->with('home')
|
||||
->with('away')
|
||||
->where('has_markets', 1)
|
||||
->where('sport_id', auth()->user()->sport_id)
|
||||
->where(function ($query) use ($element_ids) {
|
||||
$query->orWhereIn('home_id', $element_ids)->orWhereIn('away_id', $element_ids);
|
||||
});
|
||||
} else {
|
||||
$query = Event::query()
|
||||
->with('home')
|
||||
->with('away')
|
||||
->where('has_markets', 1)
|
||||
->where('sport_id', auth()->user()->sport_id);
|
||||
}
|
||||
|
||||
switch (Auth::user()->provider_id) {
|
||||
case 2:
|
||||
// BETSAPI
|
||||
return $query->where('bet365_id', 0);
|
||||
|
||||
default:
|
||||
return $query->with('event_bookmaker')->doesntHave('event_bookmaker');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Mapper;
|
||||
|
||||
class LoadGridPositions
|
||||
{
|
||||
public static function load()
|
||||
{
|
||||
// $arr = ['DR', 'MR', 'RW', 'DC', 'DM', 'MC', 'AM', 'SW', 'DC', 'DM', 'MC', 'AM', 'SM', 'ST', 'DC', 'DM', 'MC', 'AM', 'DL', 'ML', 'LM'];
|
||||
|
||||
$arr[] = 0;
|
||||
$arr[] = 0;
|
||||
$arr[] = 'SW';
|
||||
$arr[] = 0;
|
||||
$arr[] = 0;
|
||||
|
||||
$arr[] = 'DL';
|
||||
$arr[] = 'DC';
|
||||
$arr[] = 'DC';
|
||||
$arr[] = 'DC';
|
||||
$arr[] = 'DR';
|
||||
|
||||
$arr[] = 0;
|
||||
$arr[] = 'DM';
|
||||
$arr[] = 'DM';
|
||||
$arr[] = 'DM';
|
||||
$arr[] = 0;
|
||||
|
||||
$arr[] = 'MR';
|
||||
$arr[] = 'MC';
|
||||
$arr[] = 'MC';
|
||||
$arr[] = 'MC';
|
||||
$arr[] = 'ML';
|
||||
|
||||
$arr[] = 0;
|
||||
$arr[] = 'AM';
|
||||
$arr[] = 'AM';
|
||||
$arr[] = 'AM';
|
||||
$arr[] = 0;
|
||||
|
||||
$arr[] = 'RW';
|
||||
$arr[] = 0;
|
||||
$arr[] = 'SM';
|
||||
$arr[] = 0;
|
||||
$arr[] = 'LW';
|
||||
|
||||
$arr[] = 0;
|
||||
$arr[] = 0;
|
||||
$arr[] = 'ST';
|
||||
$arr[] = 0;
|
||||
$arr[] = 0;
|
||||
|
||||
$arr = array_reverse($arr);
|
||||
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Mapper;
|
||||
|
||||
use App\Models\Event;
|
||||
use App\Models\Mapper;
|
||||
|
||||
class LoadMapper
|
||||
{
|
||||
public static function load($search_values)
|
||||
{
|
||||
|
||||
$res = Event::query()->where('betradar_id', '>', 0)->pluck('betradar_id');
|
||||
|
||||
foreach ($res as $betradar_id) {
|
||||
Mapper::where('betradar_id', $betradar_id)->delete();
|
||||
}
|
||||
|
||||
if (is_array($search_values) and \count($search_values)) {
|
||||
|
||||
return Mapper::query()
|
||||
->where('sport_id', auth()->user()->sport_id)
|
||||
->where('provider_id', auth()->user()->provider_id)
|
||||
->where(function ($query) use ($search_values) {
|
||||
foreach ($search_values as $value) {
|
||||
$query->orWhere('home', 'LIKE', '%'.$value.'%')
|
||||
->orWhere('away', 'LIKE', '%'.$value.'%');
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
return Mapper::query()
|
||||
->with('country_magloo')
|
||||
->where('sport_id', auth()->user()->sport_id)
|
||||
->where('provider_id', auth()->user()->provider_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Mapper;
|
||||
|
||||
class SearchString
|
||||
{
|
||||
public static function explode($string)
|
||||
{
|
||||
$string = str_replace([',', '/', '&'], '', $string);
|
||||
|
||||
$tmp = preg_split('/\s+/', $string, -1, PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
$return = [];
|
||||
foreach ($tmp as $value) {
|
||||
if (strlen($value) > 1) {
|
||||
$return[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Mapper;
|
||||
|
||||
use App\Models\CompetitionGroupProvider;
|
||||
use App\Models\ElementProvider;
|
||||
use App\Models\Event;
|
||||
use App\Models\EventBookmaker;
|
||||
use App\Models\Mapper;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class StoreMapped
|
||||
{
|
||||
public static function store($arguments, $swopped)
|
||||
{
|
||||
|
||||
$event = Event::where('id', $arguments['id'])->first();
|
||||
|
||||
$mapper = Mapper::where('event_id', $arguments['event_id'])->first();
|
||||
|
||||
// dd($mapper, $arguments, $swopped);
|
||||
|
||||
/*
|
||||
EVENT
|
||||
"id" => 14039120
|
||||
"provider_id" => 1
|
||||
"betsapi_id" => 0
|
||||
"betradar_id" => 0
|
||||
"bet365_id" => 0
|
||||
"_1xbet_id" => 0
|
||||
"bwin_id" => 0
|
||||
"starttime" => "2026-01-02 13:00:00"
|
||||
"sport_id" => 1
|
||||
"country_id" => 365
|
||||
"group_id" => 177539
|
||||
"competition_group_id" => 141
|
||||
"home_id" => 6963
|
||||
"away_id" => 6844
|
||||
MAPPER
|
||||
"id" => 1
|
||||
"event_id" => 11208805
|
||||
"sport_id" => 1
|
||||
"provider_id" => 2
|
||||
"starttime" => "2026-01-02 05:00:00"
|
||||
"group" => "Indonesia Liga 4"
|
||||
"group_id" => 39616
|
||||
"group_cc" => "ID"
|
||||
"home" => "Boliyohuto FC"
|
||||
"home_id" => 308421
|
||||
"home_cc" => "ID"
|
||||
"away" => "Panipi Raya FC"
|
||||
"away_id" => 308005
|
||||
"away_cc" => "ID"
|
||||
"created_at" => "2026-01-02 06:33:20"
|
||||
"updated_at" => "2026-01-02 06:33:20"
|
||||
*/
|
||||
|
||||
$ele = [];
|
||||
$ele['sport_id'] = $event->sport_id;
|
||||
$ele['provider_id'] = Auth::user()->provider_id;
|
||||
$ele['element_id'] = $event->home_id ?? 0;
|
||||
$ele['add_by_method_id'] = 2;
|
||||
$ele['name'] = $mapper->home;
|
||||
ElementProvider::updateOrCreate(['provider_element_id' => (int) $mapper->home_id], $ele);
|
||||
|
||||
$ele = [];
|
||||
$ele['sport_id'] = $event->sport_id;
|
||||
$ele['provider_id'] = Auth::user()->provider_id;
|
||||
$ele['element_id'] = $event->away_id ?? 0;
|
||||
$ele['add_by_method_id'] = 2;
|
||||
$ele['name'] = $mapper->away;
|
||||
ElementProvider::updateOrCreate(['provider_element_id' => (int) $mapper->away_id], $ele);
|
||||
|
||||
$group['sport_id'] = $event->sport_id;
|
||||
$group['provider_id'] = Auth::user()->provider_id;
|
||||
$group['competition_group_id'] = $event->competition_group_id;
|
||||
$group['add_by_method_id'] = 2;
|
||||
$group['name'] = $mapper->group;
|
||||
CompetitionGroupProvider::updateOrCreate(['provider_group_id' => (int) $mapper->group_id], $group);
|
||||
|
||||
switch ($mapper->provider_id) {
|
||||
case 2:
|
||||
// BETSAPI
|
||||
$event->betsapi_id = $mapper->event_id;
|
||||
$event->bet365_id = $mapper->bet365_id ?? 0;
|
||||
break;
|
||||
case 3:
|
||||
// MAGLOO KENIA
|
||||
EventBookmaker::updateOrCreate([
|
||||
'event_id' => $arguments['id'],
|
||||
'sport_id' => $event->sport_id,
|
||||
'bookmaker_id' => 16,
|
||||
], ['starttime' => $mapper->starttime, 'in_feed' => 1, 'bmoid' => $mapper->event_id, 'is_swopped' => $swopped]);
|
||||
break;
|
||||
case 4:
|
||||
// MAGLOO NIGERIA
|
||||
EventBookmaker::updateOrCreate([
|
||||
'event_id' => $arguments['id'],
|
||||
'sport_id' => $event->sport_id,
|
||||
'bookmaker_id' => 10,
|
||||
], ['starttime' => $mapper->starttime, 'in_feed' => 1, 'bmoid' => $mapper->event_id, 'is_swopped' => $swopped]);
|
||||
break;
|
||||
case 5:
|
||||
// LOGIFUTUR NIGERA
|
||||
EventBookmaker::updateOrCreate([
|
||||
'event_id' => $arguments['id'],
|
||||
'sport_id' => $event->sport_id,
|
||||
'bookmaker_id' => 35,
|
||||
], ['starttime' => $mapper->starttime, 'in_feed' => 1, 'bmoid' => $mapper->event_id, 'is_swopped' => $swopped]);
|
||||
break;
|
||||
case 6:
|
||||
// LOGIFUTUR COLOMBIA
|
||||
EventBookmaker::updateOrCreate([
|
||||
'event_id' => $arguments['id'],
|
||||
'sport_id' => $event->sport_id,
|
||||
'bookmaker_id' => 36,
|
||||
], ['starttime' => $mapper->starttime, 'in_feed' => 1, 'bmoid' => $mapper->event_id, 'is_swopped' => $swopped]);
|
||||
break;
|
||||
}
|
||||
if ($mapper->betradar_id || $mapper->bet365_id || $mapper->betsapi_id) {
|
||||
$event->betradar_id = $mapper->betradar_id;
|
||||
$event->bet365_id = $mapper->bet365_id;
|
||||
$event->betsapi_id = $mapper->betsapi_id;
|
||||
|
||||
Mapper::where('id', $mapper->id)->delete();
|
||||
}
|
||||
$event->save();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,335 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Filament\Tables\Columns\MapperLeftColumn;
|
||||
use App\Livewire\Mapper\LoadEvents;
|
||||
use App\Livewire\Mapper\SearchString;
|
||||
use App\Livewire\Mapper\StoreMapped;
|
||||
use App\Models\CompetitionGroup;
|
||||
use App\Models\Country;
|
||||
use App\Models\Event;
|
||||
use App\Models\Mapper;
|
||||
use Carbon\Carbon;
|
||||
use CodeWithKyrian\FilamentDateRange\Forms\Components\DateRangePicker;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\Concerns\InteractsWithActions;
|
||||
use Filament\Actions\Contracts\HasActions;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
use Filament\Support\Enums\Alignment;
|
||||
use Filament\Support\Enums\Size;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Concerns\InteractsWithTable;
|
||||
use Filament\Tables\Contracts\HasTable;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Filters\Indicator;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Attributes\On;
|
||||
use Livewire\Component;
|
||||
|
||||
class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
|
||||
{
|
||||
use InteractsWithActions;
|
||||
use InteractsWithSchemas;
|
||||
use InteractsWithTable;
|
||||
|
||||
public $elements_swopped = false;
|
||||
|
||||
public $search_values = [];
|
||||
|
||||
public $search_color = 'info';
|
||||
|
||||
protected $listeners = [
|
||||
'refreshMapperLeft' => '$refresh',
|
||||
];
|
||||
|
||||
public function isRemovingAllFilters() {}
|
||||
|
||||
public function swop_elements()
|
||||
{
|
||||
$this->elements_swopped = ! $this->elements_swopped;
|
||||
}
|
||||
|
||||
public function removeTableFilter(string $filterName, ?string $field = null, bool $shouldTriggerUpdatedFiltersHook = true): void
|
||||
{
|
||||
if (($key = array_search($field, $this->search_values)) !== false) {
|
||||
unset($this->search_values[$key]);
|
||||
}
|
||||
|
||||
$this->dispatch('refreshMapperLeft');
|
||||
}
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->query(LoadEvents::load($this->search_values))
|
||||
->striped()
|
||||
->columns([
|
||||
IconColumn::make('sport.icon')
|
||||
->label('')
|
||||
->icon(fn ($record) => $record->sport->icon)
|
||||
->color(fn ($record) => $record->sport->color)
|
||||
->tooltip(fn ($record) => $record->id)
|
||||
->visibleFrom('lg'),
|
||||
IconColumn::make('country.icon')->icon(fn (string $state): string => $state)->label(''),
|
||||
TextColumn::make('competition_group.name')->label('Group')
|
||||
->wrap()
|
||||
->color('primary')
|
||||
->tooltip('Filter by group')
|
||||
->description(fn ($record): string => $record->country?->name ?? '')
|
||||
->action(function ($record) {
|
||||
if ($record?->competition_group_id ?? null && ! in_array($record->competition_group_id, $this->tableFilters['events']['competition_group_id'])) {
|
||||
$this->tableFilters['events']['competition_group_id'] = (string) $record->competition_group_id;
|
||||
$this->dispatch('refreshMapperLeft');
|
||||
}
|
||||
}),
|
||||
TextColumn::make('starttime')
|
||||
->sortable()
|
||||
->time('d. M. y H:i')
|
||||
->alignCenter(),
|
||||
MapperLeftColumn::make('left')->label('Event')->alignCenter(),
|
||||
])
|
||||
->defaultSort('starttime')
|
||||
->searchable(['home.name', 'away.name'])
|
||||
->defaultPaginationPageOption(10)
|
||||
->filters([
|
||||
Filter::make('events')
|
||||
->columns(4)
|
||||
->schema([
|
||||
Select::make('country_id')
|
||||
->placeholder('Country')
|
||||
->visible(fn () => Auth::user()->sport_id != 5)
|
||||
->hiddenLabel()
|
||||
->searchable()
|
||||
->preload()
|
||||
->options(function (Get $get) {
|
||||
$query = Event::query()->where('sport_id', Auth::user()->sport_id)->where('betradar_id', 0)->groupBy('country_id');
|
||||
|
||||
$timeframe = $get('starttime_period') ?? [];
|
||||
|
||||
if ($timeframe['start'] || $timeframe['end']) {
|
||||
if (isset($timeframe['start']) && isset($timeframe['end'])) {
|
||||
$from = Carbon::createFromDate($timeframe['start']);
|
||||
$end = Carbon::createFromDate($timeframe['end']);
|
||||
|
||||
$query->where('starttime', '>=', $from)->where('starttime', '<=', $end);
|
||||
} elseif (isset($timeframe['start'])) {
|
||||
$from = Carbon::createFromDate($timeframe['start']);
|
||||
|
||||
$query->where('starttime', '>=', $from);
|
||||
} elseif (isset($timeframe['end'])) {
|
||||
$end = Carbon::createFromDate($timeframe['end']);
|
||||
|
||||
$query->where('starttime', '<=', $end);
|
||||
}
|
||||
}
|
||||
|
||||
$res = $query->pluck('country_id')->toArray();
|
||||
|
||||
return Country::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id');
|
||||
})
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('competition_group_id', null);
|
||||
})
|
||||
->live(),
|
||||
Select::make('competition_group_id')
|
||||
->placeholder('League')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->searchable()
|
||||
->options(function (Get $get) {
|
||||
|
||||
$query = CompetitionGroup::where('sport_id', Auth::user()->sport_id)
|
||||
->whereHas('event', function ($query) {
|
||||
$query->where('betradar_id', 0);
|
||||
});
|
||||
|
||||
if ($get('country_id') ?? null) {
|
||||
$res = $query->where('country_id', $get('country_id'))->get();
|
||||
} else {
|
||||
|
||||
$timeframe = $get('starttime_period') ?? null;
|
||||
|
||||
if ($timeframe['start'] || $timeframe['end']) {
|
||||
$query->whereHas('event', function ($query) {
|
||||
if (isset($timeframe['start']) && isset($timeframe['end'])) {
|
||||
$from = Carbon::createFromDate($timeframe['start']);
|
||||
$end = Carbon::createFromDate($timeframe['end']);
|
||||
|
||||
$query->where('starttime', '>=', $from)->where('starttime', '<=', $end);
|
||||
} elseif (isset($timeframe['start'])) {
|
||||
$from = Carbon::createFromDate($timeframe['start']);
|
||||
|
||||
$query->where('starttime', '>=', $from);
|
||||
} elseif (isset($timeframe['end'])) {
|
||||
$end = Carbon::createFromDate($timeframe['end']);
|
||||
|
||||
$query->where('starttime', '<=', $end);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (Auth::user()->sport_id != 5) {
|
||||
$res = $query->groupBy('country_id')->get();
|
||||
} else {
|
||||
$res = $query->get();
|
||||
}
|
||||
}
|
||||
$arr = [];
|
||||
$map = Country::all()->pluck('name', 'id')->toArray();
|
||||
foreach ($res as $value) {
|
||||
if (isset($map[$value->country_id])) {
|
||||
$arr[$value->id] = $map[$value->country_id].' '.$value->name;
|
||||
} else {
|
||||
$arr[$value->id] = $value->name;
|
||||
}
|
||||
}
|
||||
asort($arr);
|
||||
|
||||
return $arr;
|
||||
})
|
||||
->live(),
|
||||
DateRangePicker::make('starttime_period')
|
||||
->displayFormat('d M Y')
|
||||
->columnSpan(2)
|
||||
->minDate(now())
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->live(),
|
||||
])
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
return $query
|
||||
->when(
|
||||
$data['country_id'],
|
||||
fn (Builder $query, $country_id) => $query->where('country_id', $country_id)
|
||||
)->when(
|
||||
$data['competition_group_id'],
|
||||
function (Builder $query, $competition_group_id) {
|
||||
$this->setPage(1);
|
||||
|
||||
return $query->where('competition_group_id', $competition_group_id);
|
||||
}
|
||||
)->when(
|
||||
$data['starttime_period'],
|
||||
function (Builder $query, $starttime_period) {
|
||||
|
||||
// dd($starttime_period);
|
||||
|
||||
if (isset($starttime_period['start']) && isset($starttime_period['end'])) {
|
||||
$from = Carbon::createFromDate($starttime_period['start']);
|
||||
$end = Carbon::createFromDate($starttime_period['end']);
|
||||
|
||||
return $query
|
||||
->where('starttime', '>=', $from)
|
||||
->where('starttime', '<=', $end);
|
||||
} elseif (isset($starttime_period['start'])) {
|
||||
$from = Carbon::createFromDate($starttime_period['start']);
|
||||
|
||||
return $query
|
||||
->where('starttime', '>=', $from);
|
||||
} elseif (isset($starttime_period['end'])) {
|
||||
$end = Carbon::createFromDate($starttime_period['end']);
|
||||
|
||||
return $query
|
||||
->where('starttime', '<=', $end);
|
||||
}
|
||||
});
|
||||
})->indicateUsing(function (): array {
|
||||
$indicators = [];
|
||||
if ($this->search_values) {
|
||||
foreach ($this->search_values as $value) {
|
||||
$indicators[] = Indicator::make($value)->removeField($value)->color($this->search_color);
|
||||
}
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
})
|
||||
->columns(4)->columnSpan(4),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->filtersFormColumns(3)
|
||||
->persistFiltersInSession()
|
||||
->deferFilters(false)
|
||||
->toolbarActions([
|
||||
Action::make('refresh_left')
|
||||
->hiddenLabel()
|
||||
->icon('phosphor-arrows-counter-clockwise')
|
||||
->size(Size::Small)
|
||||
->action(function (Component $livewire) {
|
||||
$this->dispatch('refreshMapperLeft');
|
||||
}),
|
||||
Action::make('reload_left')
|
||||
->hiddenLabel()
|
||||
->icon('phosphor-x')
|
||||
->size(Size::Small)
|
||||
->action(function (Component $livewire) {
|
||||
$this->search_values = [];
|
||||
$this->tableSearch = ''; // Clears the main search bar
|
||||
$livewire->fill(['tableSearch' => '']);
|
||||
$livewire->resetTableFiltersForm(); // Clears all filters
|
||||
$this->dispatch('refreshMapperLeft');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
#[On('search_left')]
|
||||
public function searchLeft($string)
|
||||
{
|
||||
$this->search_values = [];
|
||||
$this->tableSearch = ''; // Clears the main search bar
|
||||
$this->fill(['tableSearch' => '']);
|
||||
$this->resetTableFiltersForm(); // Clears all filters
|
||||
|
||||
$t = explode('|', $string);
|
||||
|
||||
$this->search_values = SearchString::explode($t[0]);
|
||||
|
||||
$this->search_color = $t[1];
|
||||
|
||||
$this->dispatch('refreshMapperLeft');
|
||||
$this->dispatch('refreshMapperRight');
|
||||
}
|
||||
|
||||
public function leftAction(): Action
|
||||
{
|
||||
return Action::make('left')
|
||||
->modalHeading('Event Mapper')
|
||||
->modalContent(function (array $arguments) {
|
||||
|
||||
$event = Event::where('id', $arguments['id'])->first();
|
||||
|
||||
$mapper = Mapper::where('event_id', $arguments['event_id'])->first();
|
||||
|
||||
return view('livewire.confirm-mapping', ['event' => $event, 'mapper' => $mapper]);
|
||||
})
|
||||
->action(function ($arguments) {
|
||||
StoreMapped::store($arguments, $this->elements_swopped);
|
||||
$this->search_values = [];
|
||||
$this->dispatch('refreshMapperLeft');
|
||||
$this->dispatch('refreshMapperRight');
|
||||
|
||||
})
|
||||
->closeModalByEscaping(false)
|
||||
->modalCloseButton(false)
|
||||
->modalCancelAction(fn (Action $action) => $action->keyBindings(['c'])->tooltip('keyboard: "c"'))
|
||||
->closeModalByClickingAway(false)
|
||||
->modalAlignment(Alignment::Center)
|
||||
->modalFooterActionsAlignment(Alignment::Center)
|
||||
->modalWidth('2xl')
|
||||
->modalSubmitActionLabel('Save')
|
||||
->modalSubmitAction(
|
||||
fn (Action $action) => $action->keyBindings(['return'])->tooltip('keyboard: "return"')
|
||||
);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
|
||||
return view('livewire.mapper-left');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,388 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Filament\Tables\Columns\MapperRightColumn;
|
||||
use App\Livewire\Mapper\LoadMapper;
|
||||
use App\Livewire\Mapper\SearchString;
|
||||
use App\Livewire\Mapper\StoreMapped;
|
||||
use App\Models\Country;
|
||||
use App\Models\Event;
|
||||
use App\Models\Mapper;
|
||||
use App\Models\Sport;
|
||||
use CodeWithKyrian\FilamentDateRange\Forms\Components\DateRangePicker;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\Concerns\InteractsWithActions;
|
||||
use Filament\Actions\Contracts\HasActions;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
use Filament\Support\Enums\Alignment;
|
||||
use Filament\Support\Enums\Size;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Concerns\InteractsWithTable;
|
||||
use Filament\Tables\Contracts\HasTable;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Filters\Indicator;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Attributes\On;
|
||||
use Livewire\Component;
|
||||
|
||||
class MapperRight extends Component implements HasActions, HasSchemas, HasTable
|
||||
{
|
||||
use InteractsWithActions;
|
||||
use InteractsWithSchemas;
|
||||
use InteractsWithTable;
|
||||
|
||||
public $elements_swopped = false;
|
||||
|
||||
public $search_values = [];
|
||||
|
||||
public $search_color = 'info';
|
||||
|
||||
protected $listeners = [
|
||||
'refreshMapperRight' => '$refresh',
|
||||
];
|
||||
|
||||
public function swop_elements()
|
||||
{
|
||||
$this->elements_swopped = ! $this->elements_swopped;
|
||||
}
|
||||
|
||||
public function removeTableFilter(string $filterName, ?string $field = null, bool $shouldTriggerUpdatedFiltersHook = true): void
|
||||
{
|
||||
if (($key = array_search($field, $this->search_values)) !== false) {
|
||||
unset($this->search_values[$key]);
|
||||
}
|
||||
|
||||
$this->dispatch('refreshMapperRight');
|
||||
}
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->query(LoadMapper::load($this->search_values))
|
||||
->striped()
|
||||
->columns([
|
||||
MapperRightColumn::make('left')->label('Event')->alignCenter(),
|
||||
TextColumn::make('starttime')
|
||||
->sortable()
|
||||
->time('d. M. y H:i')
|
||||
->alignCenter(),
|
||||
TextColumn::make('group')
|
||||
->wrap()
|
||||
->color('primary')
|
||||
->tooltip('Filter by group')
|
||||
->description(fn ($record): string => $record->country_betsapi?->name.' '.$record->country)
|
||||
->action(function ($record) {
|
||||
if ($record?->group_id ?? null && ! in_array($record->group_id, $this->tableFilters['events']['group_id'])) {
|
||||
$this->tableFilters['events']['group_id'] = (string) $record->group_id;
|
||||
$this->dispatch('refreshMapperRight');
|
||||
}
|
||||
}),
|
||||
IconColumn::make('country_magloo.icon')
|
||||
->label('')
|
||||
->icon(fn (string $state): string => $state)
|
||||
->visible(fn () => in_array(Auth::user()->provider_id, [3, 4])),
|
||||
IconColumn::make('group_cc')
|
||||
->visible(fn () => Auth::user()->provider_id == 2)
|
||||
->icon(fn (string $state): string => 'flag-country-'.$state)->label(''),
|
||||
IconColumn::make('sport.icon')
|
||||
->label('')
|
||||
->icon(fn ($record) => $record->sport->icon)
|
||||
->color(fn ($record) => $record->sport->color)
|
||||
->tooltip(fn ($record) => $record->id)
|
||||
->visibleFrom('lg'),
|
||||
])->searchable(['home', 'away'])
|
||||
->filters([
|
||||
Filter::make('events')
|
||||
->schema([
|
||||
Select::make('country_id')
|
||||
->visible(fn () => in_array(Auth::user()->provider_id, [3, 4]) && Auth::user()->sport_id != 5)
|
||||
->placeholder('Country')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->searchable()
|
||||
->preload()
|
||||
->live()
|
||||
->options(function (Get $get) {
|
||||
$query = Mapper::query()->where('sport_id', Auth::user()->sport_id)->where('provider_id', Auth::user()->provider_id);
|
||||
|
||||
$timeframe = $get('starttime_period') ?? [];
|
||||
if ($timeframe['start'] || $timeframe['end']) {
|
||||
if (isset($timeframe['start']) && isset($timeframe['end'])) {
|
||||
$from = Carbon::createFromDate($timeframe['start']);
|
||||
$end = Carbon::createFromDate($timeframe['end']);
|
||||
|
||||
$query->where('starttime', '>=', $from)->where('starttime', '<=', $end);
|
||||
} elseif (isset($timeframe['start'])) {
|
||||
$from = Carbon::createFromDate($timeframe['start']);
|
||||
|
||||
$query->where('starttime', '>=', $from);
|
||||
} elseif (isset($timeframe['end'])) {
|
||||
$end = Carbon::createFromDate($timeframe['end']);
|
||||
|
||||
$query->where('starttime', '<=', $end);
|
||||
}
|
||||
}
|
||||
|
||||
return $query->pluck('country', 'country_id')->toArray();
|
||||
})
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('group_id', null);
|
||||
})
|
||||
->placeholder('Country'),
|
||||
Select::make('group_cc')
|
||||
->visible(fn () => Auth::user()->provider_id == 2)
|
||||
->placeholder('Country')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->searchable()
|
||||
->preload()
|
||||
->live()
|
||||
->options(function (Get $get) {
|
||||
$query = Mapper::query()->where('sport_id', Auth::user()->sport_id)->where('provider_id', Auth::user()->provider_id);
|
||||
|
||||
$timeframe = $get('starttime_period') ?? [];
|
||||
|
||||
if ($timeframe['start'] || $timeframe['end']) {
|
||||
if (isset($timeframe['start']) && isset($timeframe['end'])) {
|
||||
$from = Carbon::createFromDate($timeframe['start']);
|
||||
$end = Carbon::createFromDate($timeframe['end']);
|
||||
|
||||
$query->where('starttime', '>=', $from)->where('starttime', '<=', $end);
|
||||
} elseif (isset($timeframe['start'])) {
|
||||
$from = Carbon::createFromDate($timeframe['start']);
|
||||
|
||||
$query->where('starttime', '>=', $from);
|
||||
} elseif (isset($timeframe['end'])) {
|
||||
$end = Carbon::createFromDate($timeframe['end']);
|
||||
|
||||
$query->where('starttime', '<=', $end);
|
||||
}
|
||||
}
|
||||
if ($get('country_id') ?? null) {
|
||||
$res = $query->where('country_id', $get('country_id'))->pluck('group_cc')->toArray();
|
||||
} else {
|
||||
$res = $query->pluck('group_cc')->toArray();
|
||||
}
|
||||
|
||||
return Country::query()->whereIn('iso2', $res)->orderBy('name')->pluck('name', 'iso2');
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('group_id', null);
|
||||
})
|
||||
->placeholder('Country'),
|
||||
Select::make('group_id')
|
||||
->placeholder('League')
|
||||
->label('Leagues')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->searchable()
|
||||
->preload()
|
||||
->options(function (Get $get) {
|
||||
if ($get('country_id')) {
|
||||
$query = Mapper::query()->where('sport_id', Auth::user()->sport_id)->where('provider_id', Auth::user()->provider_id)->where('country_id', $get('country_id'));
|
||||
} elseif ($get('group_cc')) {
|
||||
$query = Mapper::query()->where('sport_id', Auth::user()->sport_id)->where('provider_id', Auth::user()->provider_id)->where('group_cc', $get('group_cc'));
|
||||
} else {
|
||||
$query = Mapper::query()->where('sport_id', Auth::user()->sport_id)->where('provider_id', Auth::user()->provider_id);
|
||||
}
|
||||
|
||||
$timeframe = $get('starttime_period') ?? [];
|
||||
if ($timeframe['start'] || $timeframe['end']) {
|
||||
if (isset($timeframe['start']) && isset($timeframe['end'])) {
|
||||
$from = Carbon::createFromDate($timeframe['start']);
|
||||
$end = Carbon::createFromDate($timeframe['end']);
|
||||
|
||||
$query->where('starttime', '>=', $from)->where('starttime', '<=', $end);
|
||||
} elseif (isset($timeframe['start'])) {
|
||||
$from = Carbon::createFromDate($timeframe['start']);
|
||||
|
||||
$query->where('starttime', '>=', $from);
|
||||
} elseif (isset($timeframe['end'])) {
|
||||
$end = Carbon::createFromDate($timeframe['end']);
|
||||
|
||||
$query->where('starttime', '<=', $end);
|
||||
}
|
||||
}
|
||||
|
||||
return $query->pluck('group', 'group_id')->toArray();
|
||||
})
|
||||
->live(),
|
||||
DateRangePicker::make('starttime_period')
|
||||
->columnSpan(2)
|
||||
->displayFormat('d M Y')
|
||||
->minDate(now())
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->live(),
|
||||
])
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
return $query
|
||||
->when(
|
||||
$data['country_id'],
|
||||
fn (Builder $query, $country_id) => $query->where('country_id', $country_id)
|
||||
)->when(
|
||||
$data['group_cc'],
|
||||
fn (Builder $query, $group_cc) => $query->where('group_cc', $group_cc)
|
||||
)->when(
|
||||
$data['group_id'],
|
||||
function (Builder $query, $group_id) {
|
||||
$this->setPage(1);
|
||||
|
||||
return $query->where('group_id', $group_id);
|
||||
}
|
||||
)->when(
|
||||
$data['starttime_period'],
|
||||
function (Builder $query, $starttime_period) {
|
||||
|
||||
// dd($starttime_period);
|
||||
|
||||
if (isset($starttime_period['start']) && isset($starttime_period['end'])) {
|
||||
$from = Carbon::createFromDate($starttime_period['start']);
|
||||
$end = Carbon::createFromDate($starttime_period['end']);
|
||||
|
||||
return $query
|
||||
->where('starttime', '>=', $from)
|
||||
->where('starttime', '<=', $end);
|
||||
} elseif (isset($starttime_period['start'])) {
|
||||
$from = Carbon::createFromDate($starttime_period['start']);
|
||||
|
||||
return $query
|
||||
->where('starttime', '>=', $from);
|
||||
} elseif (isset($starttime_period['end'])) {
|
||||
$end = Carbon::createFromDate($starttime_period['end']);
|
||||
|
||||
return $query
|
||||
->where('starttime', '<=', $end);
|
||||
}
|
||||
});
|
||||
})->indicateUsing(function (): array {
|
||||
$indicators = [];
|
||||
if ($this->search_values) {
|
||||
foreach ($this->search_values as $value) {
|
||||
$indicators[] = Indicator::make($value)->removeField($value)->color($this->search_color);
|
||||
}
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
})
|
||||
->columns(4)->columnSpan(4),
|
||||
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
// IconColumn::make('search_home')->icon('phosphor-magnifying-magnifying')->label('')->color('home')->width(30),
|
||||
// IconColumn::make('search_away')->icon('phosphor-magnifying-glass')->label('')->color('away')->width(30),
|
||||
// ->hiddenFilterIndicators()
|
||||
->defaultPaginationPageOption(10)
|
||||
->persistFiltersInSession()
|
||||
->filtersFormColumns(3)
|
||||
->deferFilters(false)
|
||||
->toolbarActions([
|
||||
Action::make('refresh_right')
|
||||
->hiddenLabel()
|
||||
->tooltip('Reload')
|
||||
->icon('phosphor-arrows-counter-clockwise')
|
||||
->size(Size::Small)
|
||||
->action(function (Component $livewire) {
|
||||
$this->dispatch('refreshMapperRight');
|
||||
}),
|
||||
Action::make('reload_right')
|
||||
->hiddenLabel()
|
||||
->icon('phosphor-x')
|
||||
->tooltip('Clear Filter and Reload')
|
||||
->size(Size::Small)
|
||||
->action(function (Component $livewire) {
|
||||
$this->search_values = [];
|
||||
$this->tableSearch = ''; // Clears the main search bar
|
||||
$livewire->fill(['tableSearch' => '']);
|
||||
$livewire->resetTableFiltersForm(); // Clears all filters
|
||||
$this->dispatch('refreshMapperRight');
|
||||
}),
|
||||
Action::make('empty_mapper')
|
||||
->hiddenLabel()
|
||||
->color('danger')
|
||||
->icon('phosphor-trash')
|
||||
->tooltip('Empty Database and Reload from Provider')
|
||||
->size(Size::Small)
|
||||
->requiresConfirmation()
|
||||
->action(function (Component $livewire) {
|
||||
|
||||
Mapper::query()->where('sport_id', Auth::user()->sport_id)->where('provider_id', Auth::user()->provider_id)->delete();
|
||||
|
||||
$this->search_values = [];
|
||||
$this->tableSearch = ''; // Clears the main search bar
|
||||
$livewire->fill(['tableSearch' => '']);
|
||||
$livewire->resetTableFiltersForm(); // Clears all filters
|
||||
$this->dispatch('refreshMapperRight');
|
||||
})->successNotification(
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Events deleted')
|
||||
->body('All events for '.Sport::query()->where('id', Auth::user()->sport_id)->value('name').' has been deleted successfully. It will take up to 5 minutes to reload'),
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
#[On('search_right')]
|
||||
public function searchRight($string)
|
||||
{
|
||||
$this->search_values = [];
|
||||
$this->tableSearch = ''; // Clears the main search bar
|
||||
$this->fill(['tableSearch' => '']);
|
||||
$this->resetTableFiltersForm(); // Clears all filters
|
||||
|
||||
$t = explode('|', $string);
|
||||
$this->search_values = SearchString::explode($t[0]);
|
||||
|
||||
$this->search_color = $t[1];
|
||||
|
||||
$this->dispatch('refreshMapperRight');
|
||||
}
|
||||
|
||||
public function rightAction(): Action
|
||||
{
|
||||
return Action::make('right')
|
||||
->modalHeading('Event Mapper')
|
||||
->modalDescription('Keyboard: "enter" Save, "c" Close')
|
||||
->modalContent(function (array $arguments) {
|
||||
|
||||
$event = Event::where('id', $arguments['id'])->first();
|
||||
|
||||
$mapper = Mapper::where('event_id', $arguments['event_id'])->first();
|
||||
|
||||
return view('livewire.confirm-mapping', ['event' => $event, 'mapper' => $mapper]);
|
||||
})->action(function ($arguments) {
|
||||
StoreMapped::store($arguments, $this->elements_swopped);
|
||||
$this->search_values = [];
|
||||
$this->dispatch('refreshMapperLeft');
|
||||
$this->dispatch('refreshMapperRight');
|
||||
})
|
||||
->closeModalByEscaping(false)
|
||||
->modalCloseButton(false)
|
||||
->modalCancelAction(fn (Action $action) => $action->keyBindings(['c'])->tooltip('keyboard: "c"'))
|
||||
->closeModalByClickingAway(false)
|
||||
->modalAlignment(Alignment::Center)
|
||||
->modalFooterActionsAlignment(Alignment::Center)
|
||||
->modalWidth('2xl')
|
||||
->modalSubmitActionLabel('Save')
|
||||
->modalSubmitAction()
|
||||
->modalSubmitAction(
|
||||
fn (Action $action) => $action->keyBindings(['return'])->tooltip('keyboard: "return"')
|
||||
);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
|
||||
return view('livewire.mapper-right');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Filament\Tables\Columns\BookmakerIcon;
|
||||
use App\Models\Bookmaker;
|
||||
use App\Models\MultilineClient;
|
||||
use App\Models\MultilineSetting;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\Concerns\InteractsWithActions;
|
||||
use Filament\Actions\Contracts\HasActions;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\SelectColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Concerns\InteractsWithTable;
|
||||
use Filament\Tables\Contracts\HasTable;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Livewire\Component;
|
||||
|
||||
class MultilineBookmaker extends Component implements HasActions, HasSchemas, HasTable
|
||||
{
|
||||
use InteractsWithActions;
|
||||
use InteractsWithSchemas;
|
||||
use InteractsWithTable;
|
||||
|
||||
public $option_selected = 0;
|
||||
|
||||
protected $listeners = [
|
||||
'refreshMultilineBookmaker' => '$refresh',
|
||||
];
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->query(MultilineClient::query()->where('client_bookmaker_id', auth()->user()->bookmaker_id)->where('sport_id', auth()->user()->sport_id))
|
||||
->paginated(false)
|
||||
->columns([
|
||||
IconColumn::make('sport.icon')
|
||||
->label('')
|
||||
->width('1rem')
|
||||
->icon(function ($record): string {
|
||||
return $record->sport->icon;
|
||||
}),
|
||||
TextColumn::make('sport.name'),
|
||||
TextColumn::make('multiline_setting.name')->label('Bettype'),
|
||||
BookmakerIcon::make('bookmaker.icon')->size('xl')->label('Icon'),
|
||||
SelectColumn::make('bookmaker_id')
|
||||
->label('Bookmaker')
|
||||
->width('2rem')
|
||||
->options(function () {
|
||||
if (auth()->user()->sport_id == 1) {
|
||||
return Bookmaker::where('in_soccer', 1)->pluck('name', 'id');
|
||||
} else {
|
||||
return Bookmaker::where('in_other', 1)->pluck('name', 'id');
|
||||
}
|
||||
}),
|
||||
])
|
||||
->defaultSort('sort')
|
||||
->deferFilters(false)
|
||||
->headerActions([
|
||||
Action::make(name: 'make_all_like_selected')->action(function () {
|
||||
$res = MultilineClient::where('sport_id', auth()->user()->sport_id)
|
||||
->where('client_bookmaker_id', auth()->user()->bookmaker_id)
|
||||
->where('multiline_setting_id', $this->option_selected)->get();
|
||||
foreach ($res as $value) {
|
||||
MultilineClient::where('sport_id', auth()->user()->sport_id)
|
||||
->where('client_bookmaker_id', auth()->user()->bookmaker_id)
|
||||
->where('position', $value->position)
|
||||
->update(['bookmaker_id' => $value->bookmaker_id]);
|
||||
}
|
||||
}),
|
||||
])
|
||||
->filters([
|
||||
Filter::make('multiline_setting_id')
|
||||
->schema([
|
||||
Radio::make('multiline_setting_id')
|
||||
->extraAttributes([
|
||||
'id' => 'multiline_setting',
|
||||
'class' => 'radio-monitor-group'
|
||||
])
|
||||
->inline()
|
||||
->default(-1)
|
||||
->columnSpan(6)
|
||||
->columnSpanFull()
|
||||
->hiddenLabel()
|
||||
->options(fn () => MultilineSetting::where('sport_id', auth()->user()->sport_id)->orderBy('name')->pluck('name', 'id')),
|
||||
])
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
|
||||
$this->option_selected = $data['multiline_setting_id'];
|
||||
|
||||
return $query
|
||||
->when(
|
||||
$data['multiline_setting_id'],
|
||||
fn (Builder $query, $multiline_setting_id): Builder => $query->where('multiline_setting_id', $multiline_setting_id),
|
||||
);
|
||||
})
|
||||
->columns(6)->columnSpan(6),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->hiddenFilterIndicators();
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.multiline-bookmaker');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Console\Commands\Curl;
|
||||
use Livewire\Component;
|
||||
|
||||
class OpenExternalPage extends Component
|
||||
{
|
||||
public function txodds_odds($sportid, $txoddsid)
|
||||
{
|
||||
if ($sportid == 1) {
|
||||
$code = config('env.txodds_betaid1');
|
||||
} else {
|
||||
$code = config('env.txodds_betaid2');
|
||||
}
|
||||
|
||||
$url = "https://xml2.txodds.com/feed/odds/xml.php?$code&ot=0,4&peid=$txoddsid";
|
||||
|
||||
$request = curl_init($url);
|
||||
curl_setopt($request, CURLOPT_TIMEOUT, 30);
|
||||
curl_setopt($request, CURLOPT_CONNECTTIMEOUT, 30);
|
||||
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($request, CURLOPT_FAILONERROR, true);
|
||||
|
||||
$data = curl_exec($request);
|
||||
// header('Content-type: text/xml');
|
||||
header('Content-Type: application/xml');
|
||||
echo $data;
|
||||
exit;
|
||||
}
|
||||
|
||||
// public function betsapi_odds($eventid)
|
||||
// {
|
||||
// $code = config('env.betsapi_token');
|
||||
// $url = "https://api.b365api.com/v2/event/odds?token=$code&source=bet365&event_id=$eventid";
|
||||
// $data = Curl::load($url);
|
||||
// echo '<pre>';
|
||||
// print_r($data);
|
||||
// echo '</pre>';
|
||||
// }
|
||||
|
||||
// public function betsapi_results($bet365_id)
|
||||
// {
|
||||
// $code = config('env.betsapi_token');
|
||||
// $url = "https://api.b365api.com/v1/bet365/result?token=$code&event_id=$bet365_id";
|
||||
// $data = Curl::load($url);
|
||||
// echo '<pre>';
|
||||
// print_r($data);
|
||||
// echo '</pre>';
|
||||
// }
|
||||
|
||||
// public function betsapi_raw($bet365_id)
|
||||
// {
|
||||
// $code = config('env.betsapi_token');
|
||||
// $url = "https://api.b365api.com/v1/bet365/event?token=$code&FI=$bet365_id";
|
||||
// $data = Curl::load($url);
|
||||
// echo '<pre>';
|
||||
// print_r($data);
|
||||
// echo '</pre>';
|
||||
// }
|
||||
|
||||
// public function betsapi_lineup($eventid)
|
||||
// {
|
||||
// $code = config('env.betsapi_token');
|
||||
// $url = "https://api.b365api.com/v1/event/lineup?token=$code&event_id=$eventid";
|
||||
// $data = Curl::load($url);
|
||||
// echo '<pre>';
|
||||
// print_r($data);
|
||||
// echo '</pre>';
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Filament\Tables\Columns\BookmakerIcon;
|
||||
use App\Models\Bookmaker;
|
||||
use App\Models\PersonalNotification;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\Concerns\InteractsWithActions;
|
||||
use Filament\Actions\Contracts\HasActions;
|
||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
use Filament\Support\Enums\FontWeight;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Concerns\InteractsWithTable;
|
||||
use Filament\Tables\Contracts\HasTable;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class PersonalNotificationTable extends Component implements HasActions, HasSchemas, HasTable
|
||||
{
|
||||
use InteractsWithActions;
|
||||
use InteractsWithSchemas;
|
||||
use InteractsWithTable;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->query(PersonalNotification::query()
|
||||
->with('bookmaker')
|
||||
->where('alarm_level_id', '>', 1)
|
||||
->where('user_id', auth()->user()->id))
|
||||
->description('Send a notification when favorit enters an alarm level.')
|
||||
->striped()
|
||||
->columns([
|
||||
TextColumn::make('alarm_level.name')
|
||||
->color(fn ($record) => $record->alarm_level->color)
|
||||
->weight(FontWeight::Black),
|
||||
BookmakerIcon::make('bookmaker.icon')
|
||||
->alignCenter()
|
||||
->label('Bookmaker')->size('sm'),
|
||||
])
|
||||
->defaultSort('alarm_level_id', 'desc')
|
||||
->deferFilters(false)
|
||||
->deferFilters(false)
|
||||
->filters([
|
||||
SelectFilter::make('bookmaker_id')
|
||||
->label('Bookmaker')
|
||||
->visible(fn () => auth()->user()->partner_bookmaker_id)
|
||||
->default(auth()->user()->bookmaker->id)
|
||||
->selectablePlaceholder(false)
|
||||
->options(Bookmaker::options([auth()->user()->partner_bookmaker_id, auth()->user()->bookmaker_id]))
|
||||
->preload(),
|
||||
], FiltersLayout::AboveContent)
|
||||
->filtersFormColumns(3)
|
||||
->hiddenFilterIndicators()
|
||||
->recordActions([
|
||||
Action::make('notify_by_system')
|
||||
->button()
|
||||
->label('Send Notification')
|
||||
->color(fn ($record) => $record->notify_by_system ? 'primary' : 'gray')
|
||||
->icon('phosphor-bell-duotone')
|
||||
->action(function ($record) {
|
||||
PersonalNotification::where('id', $record->id)->update(['notify_by_system' => ! $record->notify_by_system]);
|
||||
}),
|
||||
Action::make('notify_by_email')
|
||||
->label('Send E-Mail')
|
||||
->button()
|
||||
->color(fn ($record) => $record->notify_by_email ? 'primary' : 'gray')
|
||||
->icon('phosphor-envelope-duotone')
|
||||
->action(function ($record) {
|
||||
PersonalNotification::where('id', $record->id)->update(['notify_by_email' => ! $record->notify_by_email]);
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.personal-notification-table');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Filament\Pages\Selections\LoadPositions;
|
||||
use App\Models\SofaScorePlayerPerSeason;
|
||||
use Livewire\Component;
|
||||
|
||||
class PlayerCalculator extends Component
|
||||
{
|
||||
public static function load(int $team_id)
|
||||
{
|
||||
$positions_map = LoadPositions::load();
|
||||
|
||||
$player = SofaScorePlayerPerSeason::with('details')->where('season', '=', 'total')->where('ss_team_id', '=', $team_id)->get();
|
||||
|
||||
$result = [];
|
||||
foreach ($player as $val) {
|
||||
if ($val->details != null && $val->details->is_active) {
|
||||
|
||||
$tmp = [];
|
||||
$tmp['id'] = $val->ss_player_id;
|
||||
if (! isset($val->details)) {
|
||||
$tmp['name'] = $val->ss_player_id;
|
||||
$tmp['pos_ori'] = 'GK';
|
||||
$tmp['foot'] = 'Both';
|
||||
} else {
|
||||
$tmp['name'] = $val->details->player_name;
|
||||
$tmp['pos_ori'] = $val->details->position;
|
||||
$tmp['foot'] = $val->details->preferred_foot;
|
||||
}
|
||||
$tmp['pos'] = '';
|
||||
$tmp['active'] = 0;
|
||||
$tmp['tot_evt'] = $val->total_events;
|
||||
$tmp['tot_min'] = $val->total_min;
|
||||
$tmp['ave_min'] = $val->average_min;
|
||||
$tmp['gls'] = $val->goals;
|
||||
$tmp['fls'] = $val->fouls;
|
||||
$tmp['ofs'] = $val->offsides;
|
||||
$tmp['crd'] = $val->cards;
|
||||
$tmp['snt'] = $val->shots_on_target;
|
||||
$tmp['tsh'] = $val->shots_off_target;
|
||||
|
||||
$level = round($val->total_events / 3);
|
||||
if ($val->total_events) {
|
||||
if ($level > 1 && $val->total_events < $level) {
|
||||
$tmp['color_evt'] = 'danger';
|
||||
} elseif ($val->total_events < $level * 2) {
|
||||
$tmp['color_evt'] = 'info';
|
||||
} else {
|
||||
$tmp['color_evt'] = 'success';
|
||||
}
|
||||
}
|
||||
|
||||
if (! isset($val->details)) {
|
||||
$tmp['area'] = 'goalkeeper';
|
||||
$tmp['color_pos'] = 'gray';
|
||||
$tmp['order'] = 5;
|
||||
} else {
|
||||
if (in_array($val->details->position, $positions_map['MIDFIELD'])) {
|
||||
$tmp['area'] = 'midfield';
|
||||
$tmp['color_pos'] = 'info';
|
||||
$tmp['order'] = 2;
|
||||
} elseif (in_array($val->details->position, $positions_map['DEFENCE'])) {
|
||||
$tmp['area'] = 'defence';
|
||||
$tmp['color_pos'] = 'success';
|
||||
$tmp['order'] = 1;
|
||||
} elseif (in_array($val->details->position, $positions_map['ATTACK'])) {
|
||||
$tmp['area'] = 'attack';
|
||||
$tmp['color_pos'] = 'warning';
|
||||
$tmp['order'] = 3;
|
||||
} elseif (in_array($val->details->position, $positions_map['GOALKEEPER'])) {
|
||||
$tmp['area'] = 'goalkeeper';
|
||||
$tmp['color_pos'] = 'gray';
|
||||
$tmp['order'] = 4;
|
||||
} else {
|
||||
$tmp['area'] = 'defence';
|
||||
$tmp['color_pos'] = 'success';
|
||||
$tmp['order'] = 5;
|
||||
}
|
||||
}
|
||||
|
||||
$result[] = $tmp;
|
||||
}
|
||||
}
|
||||
|
||||
// dd($result);
|
||||
|
||||
// $pos = array_column($result, 'pos');
|
||||
// $area = array_column($result, 'area');
|
||||
// array_multisort($area, SORT_ASC, $pos, SORT_ASC, $result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\Client;
|
||||
use App\Models\Sport;
|
||||
use App\Models\User;
|
||||
use Livewire\Component;
|
||||
|
||||
class SportSwitcher extends Component
|
||||
{
|
||||
public $sports = [];
|
||||
|
||||
public $sport_id = 0;
|
||||
|
||||
public $sporticon = '';
|
||||
|
||||
public $iconcolor = '';
|
||||
|
||||
protected $listeners = [
|
||||
'refreshSportSwitcher' => '$refresh',
|
||||
];
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$cps = Client::where('id', auth()->user()->client_id)->pluck('sport')->first();
|
||||
|
||||
$this->sports = Sport::whereIn('id', $cps)->pluck('name', 'id');
|
||||
|
||||
$this->sporticon = Sport::where('id', auth()->user()->sport_id)->pluck('icon')->first();
|
||||
|
||||
$this->iconcolor = Sport::where('id', auth()->user()->sport_id)->pluck('color')->first();
|
||||
|
||||
$this->sport_id = auth()->user()->sport_id;
|
||||
|
||||
}
|
||||
|
||||
public function swopSport()
|
||||
{
|
||||
User::where('id', auth()->user()->id)->update(['sport_id' => $this->sport_id]);
|
||||
|
||||
$this->sporticon = Sport::where('id', $this->sport_id)->pluck('icon')->first();
|
||||
|
||||
$this->iconcolor = Sport::where('id', $this->sport_id)->pluck('color')->first();
|
||||
|
||||
$this->dispatch('filterClearFilter');
|
||||
|
||||
$this->js('window.location.reload()');
|
||||
|
||||
// $this->dispatch('refreshSportSwitcher');
|
||||
|
||||
// $this->dispatch('refreshBettypeMenu');
|
||||
|
||||
// $this->dispatch('refreshMultilineBookmaker');
|
||||
|
||||
// $this->dispatch('refreshComparingBookmakerMenu');
|
||||
|
||||
// $this->dispatch('refreshAlarmBookmaker');
|
||||
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.sport-switcher');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\Provider;
|
||||
use App\Models\Sport;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Livewire\Component;
|
||||
|
||||
class TopMenuItems extends Component
|
||||
{
|
||||
public $current = '';
|
||||
|
||||
protected $listeners = [
|
||||
'refreshMapperLeft' => '$refresh',
|
||||
'refreshMapperRight' => '$refresh',
|
||||
];
|
||||
|
||||
protected string $sport = '';
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->current = Route::currentRouteName();
|
||||
|
||||
}
|
||||
|
||||
public function setUser()
|
||||
{
|
||||
$user = User::find(auth()->user()->id);
|
||||
|
||||
$this->sport = Sport::where('id', $user->sport_id)->value('name');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.top-menu-items', ['sport' => $this->sport]);
|
||||
}
|
||||
|
||||
public function swopBookmaker($bookmaker_id)
|
||||
{
|
||||
$provider_id = Provider::where('bookmaker_id', $bookmaker_id)->value('id');
|
||||
|
||||
User::where('id', auth()->user()->id)->update(['provider_id' => $provider_id, 'bookmaker_id' => $bookmaker_id, 'partner_bookmaker_id' => auth()->user()->bookmaker_id]);
|
||||
|
||||
$this->js('window.location.reload()');
|
||||
}
|
||||
|
||||
public function swopProvider($provider_id)
|
||||
{
|
||||
User::where('id', auth()->user()->id)->update(['provider_id' => $provider_id]);
|
||||
|
||||
$this->dispatch('refreshMapperRight');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Mail\UserNotification;
|
||||
use App\Models\User;
|
||||
use Filament\Actions\Concerns\InteractsWithActions;
|
||||
use Filament\Actions\Contracts\HasActions;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Concerns\InteractsWithTable;
|
||||
use Filament\Tables\Contracts\HasTable;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Livewire\Component;
|
||||
|
||||
class UserNotifications extends Component implements HasActions, HasSchemas, HasTable
|
||||
{
|
||||
use InteractsWithActions;
|
||||
use InteractsWithSchemas;
|
||||
use InteractsWithTable;
|
||||
|
||||
public ?array $data = [];
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->form->fill();
|
||||
}
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Select::make('recipient')
|
||||
->placeholder('Select an recipient')
|
||||
->required()
|
||||
->options(fn () => User::query()->where('client_id', auth()->user()->client_id)->orwhereIn('id', [1, 2])->pluck('name', 'id')),
|
||||
Toggle::make('notify_by_email')->label('Send also as E-Mail'),
|
||||
Textarea::make('message')->rows(4)
|
||||
->required(),
|
||||
])
|
||||
->statePath('data');
|
||||
}
|
||||
|
||||
public function create(): void
|
||||
{
|
||||
$data = $this->form->getState();
|
||||
|
||||
$recipient = User::find((int) $data['recipient']);
|
||||
|
||||
if ($recipient) {
|
||||
if ($data['notify_by_email']) {
|
||||
Mail::to($recipient)->send(new UserNotification($data['message']));
|
||||
}
|
||||
Notification::make()
|
||||
->title($data['message'])
|
||||
->icon('phosphor-user-duotone')
|
||||
->body('from: '.auth()->user()->name)
|
||||
->sendToDatabase($recipient);
|
||||
|
||||
Notification::make()
|
||||
->title('Message send successfully')
|
||||
->success()
|
||||
->send();
|
||||
|
||||
$this->dispatch('close-modal', id: 'send_message_modal');
|
||||
}
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.user-notifications');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user