Skip to content

Commit

Permalink
Added sort for admin santa
Browse files Browse the repository at this point in the history
  • Loading branch information
tabuna committed Dec 24, 2024
1 parent 25410fa commit 1062678
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 7 additions & 1 deletion app/Models/SecretSantaParticipant.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -27,6 +28,11 @@ class SecretSantaParticipant extends Model
'santa',
];

protected $allowedSorts = [
'status',
'tracking_number',
];

// Связь с пользователем
public function user()
{
Expand Down
9 changes: 5 additions & 4 deletions app/Orchid/Screens/SecretSantaScreen.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
];
}

Expand Down Expand Up @@ -71,7 +72,6 @@ public function layout(): array
->title('Статус участника')
->options([
'new' => 'Новый',
'pending' => 'Ожидает',
'in_progress' => 'В процессе',
'done' => 'Завершён',
])
Expand Down Expand Up @@ -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'
? '✅ Завершён'
: '⏳ Ожидает'
Expand Down

0 comments on commit 1062678

Please sign in to comment.