Edit SofaScore Tasks add filter
This commit is contained in:
1 parent
210aed8c97
commit
b25cf15a9e
10 files changed
+120
-39
No files matched your search
@@ -7,7 +7,7 @@ use App\Console\Commands\Grapper\Sofascore\Helper\LoadDays;
|
|||||||
use App\Console\Commands\Grapper\Sofascore\Helper\Sleeper;
|
use App\Console\Commands\Grapper\Sofascore\Helper\Sleeper;
|
||||||
use App\Console\Commands\Nuh;
|
use App\Console\Commands\Nuh;
|
||||||
use App\Models\Country;
|
use App\Models\Country;
|
||||||
use App\Models\SofaScoreCategorie;
|
use App\Models\SofaScoreCategory;
|
||||||
use App\Models\SofaScoreDayTournament;
|
use App\Models\SofaScoreDayTournament;
|
||||||
use App\Models\SofaScoreTournament;
|
use App\Models\SofaScoreTournament;
|
||||||
use App\Utilities\Notice;
|
use App\Utilities\Notice;
|
||||||
@@ -126,9 +126,9 @@ class DaysTournament
|
|||||||
// CATEGORY find <-> replace
|
// CATEGORY find <-> replace
|
||||||
Log::channel('sofascore')->info($tournament);
|
Log::channel('sofascore')->info($tournament);
|
||||||
|
|
||||||
$sofa_score_categorie_id = 10000000;
|
$sofa_score_category_id = 10000000;
|
||||||
} else {
|
} else {
|
||||||
$call = SofaScoreCategorie::updateOrCreate([
|
$call = SofaScoreCategory::updateOrCreate([
|
||||||
'id' => (int) $category['id'],
|
'id' => (int) $category['id'],
|
||||||
'country_id' => (int) $country_id,
|
'country_id' => (int) $country_id,
|
||||||
'slug' => $category['slug'],
|
'slug' => $category['slug'],
|
||||||
@@ -136,7 +136,7 @@ class DaysTournament
|
|||||||
'name' => $category['name'],
|
'name' => $category['name'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$sofa_score_categorie_id = $call->id;
|
$sofa_score_category_id = $call->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -145,7 +145,7 @@ class DaysTournament
|
|||||||
SofaScoreTournament::updateOrCreate([
|
SofaScoreTournament::updateOrCreate([
|
||||||
'sport_id' => (int) $sport_id,
|
'sport_id' => (int) $sport_id,
|
||||||
'tournament_id' => (int) $tournament['id'],
|
'tournament_id' => (int) $tournament['id'],
|
||||||
'sofa_score_categorie_id' => (int) $sofa_score_categorie_id,
|
'sofa_score_category_id' => (int) $sofa_score_category_id,
|
||||||
], [
|
], [
|
||||||
'name' => $tournament['name'],
|
'name' => $tournament['name'],
|
||||||
'slug' => $tournament['slug'],
|
'slug' => $tournament['slug'],
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use App\Models\SofaScoreDayTournament;
|
|||||||
use App\Models\SofaScoreEventGrapped;
|
use App\Models\SofaScoreEventGrapped;
|
||||||
use App\Models\SofaScoreTaskDay;
|
use App\Models\SofaScoreTaskDay;
|
||||||
use App\Models\SofaScoreTaskTournament;
|
use App\Models\SofaScoreTaskTournament;
|
||||||
|
use App\Models\SofaScoreTournament;
|
||||||
use App\Utilities\Notice;
|
use App\Utilities\Notice;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Facades\File;
|
use Illuminate\Support\Facades\File;
|
||||||
@@ -19,6 +20,7 @@ class Rose
|
|||||||
{
|
{
|
||||||
public static function run()
|
public static function run()
|
||||||
{
|
{
|
||||||
|
|
||||||
$debug = Nuh::$options['d'] ?? 0;
|
$debug = Nuh::$options['d'] ?? 0;
|
||||||
|
|
||||||
$task_id = Nuh::$options['task'] ?? 0;
|
$task_id = Nuh::$options['task'] ?? 0;
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands\Grapper\Sofascore;
|
||||||
|
|
||||||
|
use App\Models\SofaScoreTaskTournament;
|
||||||
|
use App\Models\SofaScoreTournament;
|
||||||
|
use App\Utilities\Notice;
|
||||||
|
|
||||||
|
class SqlMover
|
||||||
|
{
|
||||||
|
public static function run()
|
||||||
|
{
|
||||||
|
|
||||||
|
$res = SofaScoreTaskTournament::get();
|
||||||
|
|
||||||
|
foreach ($res as $value) {
|
||||||
|
$res2 = SofaScoreTournament::where('tournament_id', $value->sofa_score_tournament_id)->first();
|
||||||
|
|
||||||
|
SofaScoreTaskTournament::where('id', $value->id)->update(['sofa_score_category_id' => $res2->sofa_score_category_id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Notice::note('done', 'bb', 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
+67
-19
@@ -2,12 +2,14 @@
|
|||||||
|
|
||||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\RelationManagers;
|
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\RelationManagers;
|
||||||
|
|
||||||
use App\Models\SofaScoreCategorie;
|
use App\Models\SofaScoreCategory;
|
||||||
|
use App\Models\SofaScoreTaskTournament;
|
||||||
use App\Models\SofaScoreTournament;
|
use App\Models\SofaScoreTournament;
|
||||||
|
use Filament\Actions\Action;
|
||||||
|
use Filament\Actions\BulkAction;
|
||||||
use Filament\Actions\BulkActionGroup;
|
use Filament\Actions\BulkActionGroup;
|
||||||
use Filament\Actions\CreateAction;
|
use Filament\Actions\CreateAction;
|
||||||
use Filament\Actions\DeleteAction;
|
use Filament\Actions\DeleteAction;
|
||||||
use Filament\Actions\DeleteBulkAction;
|
|
||||||
use Filament\Actions\EditAction;
|
use Filament\Actions\EditAction;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Resources\RelationManagers\RelationManager;
|
use Filament\Resources\RelationManagers\RelationManager;
|
||||||
@@ -16,7 +18,10 @@ use Filament\Schemas\Schema;
|
|||||||
use Filament\Support\Enums\FontWeight;
|
use Filament\Support\Enums\FontWeight;
|
||||||
use Filament\Tables\Columns\TextColumn;
|
use Filament\Tables\Columns\TextColumn;
|
||||||
use Filament\Tables\Columns\ToggleColumn;
|
use Filament\Tables\Columns\ToggleColumn;
|
||||||
|
use Filament\Tables\Enums\FiltersLayout;
|
||||||
|
use Filament\Tables\Filters\SelectFilter;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
class SofaScoreTaskTournamentsRelationManager extends RelationManager
|
class SofaScoreTaskTournamentsRelationManager extends RelationManager
|
||||||
{
|
{
|
||||||
@@ -29,20 +34,20 @@ class SofaScoreTaskTournamentsRelationManager extends RelationManager
|
|||||||
protected static ?string $modelLabel = 'Tournament';
|
protected static ?string $modelLabel = 'Tournament';
|
||||||
|
|
||||||
protected static ?string $pluralModelLabel = 'Tournaments';
|
protected static ?string $pluralModelLabel = 'Tournaments';
|
||||||
|
|
||||||
public function form(Schema $schema): Schema
|
public function form(Schema $schema): Schema
|
||||||
{
|
{
|
||||||
return $schema
|
return $schema
|
||||||
->components([
|
->components([
|
||||||
Select::make('sofa_score_categorie_id')
|
Select::make('sofa_score_category_id')
|
||||||
->searchable()
|
->searchable()
|
||||||
->label('Categorie')
|
->label('Category')
|
||||||
->options(function (Get $get) {
|
->options(function () {
|
||||||
$res = SofaScoreTournament::where('sport_id', $this->getOwnerRecord()['sport_id'])
|
$res = SofaScoreTournament::where('sport_id', $this->getOwnerRecord()['sport_id'])
|
||||||
->groupBy('sofa_score_categorie_id')
|
->groupBy('sofa_score_category_id')
|
||||||
->pluck('sofa_score_categorie_id')
|
->pluck('sofa_score_category_id')
|
||||||
->toArray();
|
->toArray();
|
||||||
return SofaScoreCategorie::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id');
|
return SofaScoreCategory::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id');
|
||||||
})
|
})
|
||||||
->live(),
|
->live(),
|
||||||
Select::make('sofa_score_tournament_id')
|
Select::make('sofa_score_tournament_id')
|
||||||
@@ -50,10 +55,10 @@ class SofaScoreTaskTournamentsRelationManager extends RelationManager
|
|||||||
->label('Tournament')
|
->label('Tournament')
|
||||||
->placeholder('Select a categorie first.')
|
->placeholder('Select a categorie first.')
|
||||||
->noOptionsMessage('Select a categorie first.')
|
->noOptionsMessage('Select a categorie first.')
|
||||||
->disabled(fn (Get $get):bool => (bool) $get('sofa_score_categorie_id') ? false : true)
|
->disabled(fn(Get $get): bool => (bool) $get('sofa_score_category_id') ? false : true)
|
||||||
->options(fn (Get $get) => SofaScoreTournament::where('sport_id', $this->getOwnerRecord()['sport_id'])
|
->options(fn(Get $get) => SofaScoreTournament::where('sport_id', $this->getOwnerRecord()['sport_id'])
|
||||||
->where('disabled', 0)
|
->where('disabled', 0)
|
||||||
->where('sofa_score_categorie_id', $get('sofa_score_categorie_id'))
|
->where('sofa_score_category_id', $get('sofa_score_category_id'))
|
||||||
->orderBY('name')
|
->orderBY('name')
|
||||||
->pluck('name', 'tournament_id')),
|
->pluck('name', 'tournament_id')),
|
||||||
]);
|
]);
|
||||||
@@ -63,30 +68,73 @@ class SofaScoreTaskTournamentsRelationManager extends RelationManager
|
|||||||
{
|
{
|
||||||
return $table
|
return $table
|
||||||
->columns([
|
->columns([
|
||||||
TextColumn::make('tournament.sofascore_category.name')
|
TextColumn::make('category.name')
|
||||||
->label('Country')
|
->label('Category')
|
||||||
->searchable(),
|
->searchable(),
|
||||||
TextColumn::make('tournament.name')
|
TextColumn::make('tournament.name')
|
||||||
->weight(FontWeight::Bold)
|
->weight(FontWeight::Bold)
|
||||||
->searchable(),
|
->searchable(),
|
||||||
ToggleColumn::make('disabled')
|
ToggleColumn::make('disabled')
|
||||||
|
->onColor('danger')
|
||||||
->alignCenter(),
|
->alignCenter(),
|
||||||
])
|
])
|
||||||
->filters([
|
->filters([
|
||||||
//
|
SelectFilter::make('sofa_score_category_id')
|
||||||
])
|
->searchable()
|
||||||
|
->label('Categorie')
|
||||||
|
->options(function () {
|
||||||
|
$res = SofaScoreTaskTournament::where('sofa_score_task_id', $this->getOwnerRecord()['id'])
|
||||||
|
->groupBy('sofa_score_category_id')
|
||||||
|
->pluck('sofa_score_category_id')
|
||||||
|
->toArray();
|
||||||
|
return SofaScoreCategory::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id');
|
||||||
|
})
|
||||||
|
], layout: FiltersLayout::AboveContent)
|
||||||
|
->deferFilters(false)
|
||||||
->headerActions([
|
->headerActions([
|
||||||
|
Action::make('all_on')
|
||||||
|
->icon('phosphor-toggle-right-fill')
|
||||||
|
->action(function (): void {
|
||||||
|
SofaScoreTaskTournament::where('sofa_score_task_id', $this->getOwnerRecord()['id'])->update(['disabled' => 0]);
|
||||||
|
}),
|
||||||
|
Action::make('all_off')
|
||||||
|
->icon('phosphor-toggle-left-fill')
|
||||||
|
->color('danger')
|
||||||
|
->action(function (): void {
|
||||||
|
SofaScoreTaskTournament::where('sofa_score_task_id', $this->getOwnerRecord()['id'])->update(['disabled' => 1]);
|
||||||
|
}),
|
||||||
CreateAction::make()
|
CreateAction::make()
|
||||||
->icon('phosphor-plus')
|
->icon('phosphor-plus')
|
||||||
->label('Tournament'),
|
->label('Tournament'),
|
||||||
])
|
])
|
||||||
->recordActions([
|
->recordActions([
|
||||||
EditAction::make(),
|
EditAction::make()->iconButton(),
|
||||||
DeleteAction::make(),
|
DeleteAction::make()->iconButton(),
|
||||||
])
|
])
|
||||||
->toolbarActions([
|
->toolbarActions([
|
||||||
BulkActionGroup::make([
|
BulkActionGroup::make([
|
||||||
DeleteBulkAction::make(),
|
BulkAction::make('Disable selected')
|
||||||
|
->icon('phosphor-toggle-left-fill')
|
||||||
|
->color('danger')
|
||||||
|
->action(function (Collection $records): void {
|
||||||
|
foreach ($records as $record) {
|
||||||
|
SofaScoreTaskTournament::where('id', '=', $record->id)
|
||||||
|
->update(
|
||||||
|
['disabled' => 1]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
BulkAction::make('Enable selected')
|
||||||
|
->icon('phosphor-toggle-right-fill')
|
||||||
|
->action(function (Collection $records): void {
|
||||||
|
foreach ($records as $record) {
|
||||||
|
SofaScoreTaskTournament::where('id', '=', $record->id)
|
||||||
|
->update(
|
||||||
|
['disabled' => 0]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
// DeleteBulkAction::make(),
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-11
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Tables;
|
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Tables;
|
||||||
|
|
||||||
use App\Models\SofaScoreCategorie;
|
use App\Models\SofaScoreCategory;
|
||||||
use App\Models\SofaScoreTournament;
|
use App\Models\SofaScoreTournament;
|
||||||
use App\Models\Sport;
|
use App\Models\Sport;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
@@ -54,21 +54,21 @@ class SofaScoreTournamentsTable
|
|||||||
->label('Sport')
|
->label('Sport')
|
||||||
->options(Sport::where('is_active', 1)->pluck('name', 'id'))
|
->options(Sport::where('is_active', 1)->pluck('name', 'id'))
|
||||||
->afterStateUpdated(function (callable $set) {
|
->afterStateUpdated(function (callable $set) {
|
||||||
$set('sofa_score_categorie_id', null);
|
$set('sofa_score_category_id', null);
|
||||||
})
|
})
|
||||||
->live(),
|
->live(),
|
||||||
Select::make('sofa_score_categorie_id')
|
Select::make('sofa_score_category_id')
|
||||||
->searchable()
|
->searchable()
|
||||||
->multiple()
|
->multiple()
|
||||||
->columnSpan(2)
|
->columnSpan(2)
|
||||||
->label('Categorie')
|
->label('Categorie')
|
||||||
->options(function (Get $get) {
|
->options(function (Get $get) {
|
||||||
$res = SofaScoreTournament::where('sport_id', $get('sport_id'))
|
$res = SofaScoreTournament::where('sport_id', $get('sport_id'))
|
||||||
->groupBy('sofa_score_categorie_id')
|
->groupBy('sofa_score_category_id')
|
||||||
->pluck('sofa_score_categorie_id')
|
->pluck('sofa_score_category_id')
|
||||||
->toArray();
|
->toArray();
|
||||||
|
|
||||||
return SofaScoreCategorie::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id');
|
return SofaScoreCategory::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id');
|
||||||
})
|
})
|
||||||
->live(),
|
->live(),
|
||||||
ToggleButtons::make('filter-disabled')
|
ToggleButtons::make('filter-disabled')
|
||||||
@@ -86,12 +86,12 @@ class SofaScoreTournamentsTable
|
|||||||
$data['sport_id'],
|
$data['sport_id'],
|
||||||
fn(Builder $query, $sport_id) => $query->where('sport_id', $sport_id)
|
fn(Builder $query, $sport_id) => $query->where('sport_id', $sport_id)
|
||||||
)->when(
|
)->when(
|
||||||
$data['sofa_score_categorie_id'],
|
$data['sofa_score_category_id'],
|
||||||
function (Builder $query, $sofa_score_categorie_id) {
|
function (Builder $query, $sofa_score_category_id) {
|
||||||
if (is_array($sofa_score_categorie_id)) {
|
if (is_array($sofa_score_category_id)) {
|
||||||
$query->whereIn('sofa_score_categorie_id', $sofa_score_categorie_id);
|
$query->whereIn('sofa_score_category_id', $sofa_score_category_id);
|
||||||
} else {
|
} else {
|
||||||
$query->where('sofa_score_categorie_id', $sofa_score_categorie_id);
|
$query->where('sofa_score_category_id', $sofa_score_category_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// )->when(
|
// )->when(
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ namespace App\Models;
|
|||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class SofaScoreCategorie extends Model
|
class SofaScoreCategory extends Model
|
||||||
{
|
{
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'id',
|
'id',
|
||||||
@@ -9,6 +9,7 @@ class SofaScoreTaskTournament extends Model
|
|||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'sofa_score_task_id',
|
'sofa_score_task_id',
|
||||||
'sofa_score_tournament_id',
|
'sofa_score_tournament_id',
|
||||||
|
'sofa_score_category_id',
|
||||||
'disabled',
|
'disabled',
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -21,4 +22,9 @@ class SofaScoreTaskTournament extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsTo(SofaScoreTournament::class, 'sofa_score_tournament_id', 'tournament_id');
|
return $this->belongsTo(SofaScoreTournament::class, 'sofa_score_tournament_id', 'tournament_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function category()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(SofaScoreCategory::class, 'sofa_score_category_id', 'id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@ class SofaScoreTournament extends Model
|
|||||||
'id',
|
'id',
|
||||||
'sport_id',
|
'sport_id',
|
||||||
'tournament_id',
|
'tournament_id',
|
||||||
'sofa_score_categorie_id',
|
'sofa_score_category_id',
|
||||||
'name',
|
'name',
|
||||||
'slug',
|
'slug',
|
||||||
'enabled',
|
'enabled',
|
||||||
@@ -23,6 +23,6 @@ class SofaScoreTournament extends Model
|
|||||||
|
|
||||||
public function sofascore_category()
|
public function sofascore_category()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(SofaScoreCategorie::class, 'sofa_score_categorie_id', 'id');
|
return $this->belongsTo(SofaScoreCategory::class, 'sofa_score_category_id', 'id');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,7 @@ return new class extends Migration
|
|||||||
$table->id();
|
$table->id();
|
||||||
$table->integer('sport_id')->index()->references('id')->on('sports');
|
$table->integer('sport_id')->index()->references('id')->on('sports');
|
||||||
$table->integer('tournament_id')->index();
|
$table->integer('tournament_id')->index();
|
||||||
$table->integer('sofa_score_categorie_id')->index();
|
$table->integer('sofa_score_category_id')->index();
|
||||||
$table->string('slug')->index();
|
$table->string('slug')->index();
|
||||||
$table->string('name');
|
$table->string('name');
|
||||||
$table->boolean('enabled')->index()->default(0);
|
$table->boolean('enabled')->index()->default(0);
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ return new class extends Migration
|
|||||||
$table->id();
|
$table->id();
|
||||||
$table->integer('sofa_score_task_id');
|
$table->integer('sofa_score_task_id');
|
||||||
$table->integer('sofa_score_tournament_id');
|
$table->integer('sofa_score_tournament_id');
|
||||||
|
$table->integer('sofa_score_category_id');
|
||||||
$table->boolean('disabled')->default(0);
|
$table->boolean('disabled')->default(0);
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user