From 10626787d56a9117f1f6a30a0a004e52f4cf0480 Mon Sep 17 00:00:00 2001 From: Alexandr Chernyaev Date: Tue, 24 Dec 2024 18:19:35 +0300 Subject: [PATCH] Added sort for admin santa --- app/Models/SecretSantaParticipant.php | 8 +++++++- app/Orchid/Screens/SecretSantaScreen.php | 9 +++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/Models/SecretSantaParticipant.php b/app/Models/SecretSantaParticipant.php index 99a4aa71..d6abc769 100644 --- a/app/Models/SecretSantaParticipant.php +++ b/app/Models/SecretSantaParticipant.php @@ -5,11 +5,12 @@ use Illuminate\Database\Eloquent\Concerns\HasUuids; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; +use Orchid\Filters\Filterable; use Orchid\Screen\AsSource; class SecretSantaParticipant extends Model { - use AsSource, HasUuids, SoftDeletes; + use AsSource, HasUuids, SoftDeletes, Filterable; protected $fillable = [ 'address', @@ -27,6 +28,11 @@ class SecretSantaParticipant extends Model 'santa', ]; + protected $allowedSorts = [ + 'status', + 'tracking_number', + ]; + // Связь с пользователем public function user() { diff --git a/app/Orchid/Screens/SecretSantaScreen.php b/app/Orchid/Screens/SecretSantaScreen.php index bff1e933..e0d3c6d4 100644 --- a/app/Orchid/Screens/SecretSantaScreen.php +++ b/app/Orchid/Screens/SecretSantaScreen.php @@ -23,7 +23,8 @@ class SecretSantaScreen extends Screen public function query(): iterable { return [ - 'participants' => SecretSantaParticipant::with(['receiver', 'santa', 'user'])->get(), + 'participants' => SecretSantaParticipant::with(['receiver', 'santa', 'user']) + ->get(), ]; } @@ -71,7 +72,6 @@ public function layout(): array ->title('Статус участника') ->options([ 'new' => 'Новый', - 'pending' => 'Ожидает', 'in_progress' => 'В процессе', 'done' => 'Завершён', ]) @@ -112,10 +112,11 @@ public function layout(): array ); }), - TD::make('tracking_number', 'Трек-номер'), + TD::make('tracking_number', 'Трек-номер')->sort(), TD::make('status', 'Статус') - ->width(100) + ->width(150) + ->sort() ->render(fn (SecretSantaParticipant $participant) => $participant->status === 'done' ? '✅ Завершён' : '⏳ Ожидает'