Skip to content

Commit b337f6b

Browse files
committed
Added init page for admin secret-santa
1 parent 3e79e2b commit b337f6b

File tree

3 files changed

+93
-0
lines changed

3 files changed

+93
-0
lines changed

app/Orchid/PlatformProvider.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ public function menu(): array
103103
->route('platform.services.telescope')
104104
->permission('platform.services.telescope'),
105105

106+
Menu::make('Секретный Санта')
107+
->route('platform.secret-santa')
108+
->icon('gift'),
109+
106110
Menu::make(__('Users'))
107111
->icon('bs.people')
108112
->route('platform.systems.users')
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
3+
namespace App\Orchid\Screens;
4+
5+
use App\Models\SecretSantaParticipant;
6+
use Orchid\Screen\Actions\Link;
7+
use Orchid\Screen\Screen;
8+
use Orchid\Screen\TD;
9+
use Orchid\Support\Facades\Layout;
10+
11+
class SecretSantaScreen extends Screen
12+
{
13+
/**
14+
* Query data.
15+
*
16+
* @return array
17+
*/
18+
public function query(): iterable
19+
{
20+
return [
21+
'participants' => SecretSantaParticipant::with(['receiver', 'santa', 'user'])->all(),
22+
];
23+
}
24+
25+
/**
26+
* Display heading of the screen.
27+
*
28+
* @var string
29+
*/
30+
public function name(): string
31+
{
32+
return 'Участники Тайного Санты';
33+
}
34+
35+
/**
36+
* Screen description.
37+
*
38+
* @var string
39+
*/
40+
public function description(): string
41+
{
42+
return 'Список участников и управление связями между ними';
43+
}
44+
45+
/**
46+
* Screen layout.
47+
*
48+
* @return array
49+
*/
50+
public function layout(): array
51+
{
52+
return [
53+
Layout::table('participants', [
54+
TD::make('user.name', 'Пользователь')
55+
->width('20%'),
56+
57+
TD::make('receiver', 'Получатель')
58+
->width('20%')
59+
->render(fn(SecretSantaParticipant $participant) => $participant->receiver?->user->name ?? 'Не назначен'
60+
),
61+
62+
TD::make('santa', 'Санта')
63+
->width('20%')
64+
->align(TD::ALIGN_CENTER)
65+
->render(fn(SecretSantaParticipant $participant) => $participant->santa?->user->name ?? 'Не назначен'
66+
),
67+
68+
TD::make('address', 'Адрес')
69+
->width('25%'),
70+
71+
TD::make('telegram', 'Telegram')
72+
->width('15%')
73+
->render(fn(SecretSantaParticipant $participant) => $participant->telegram
74+
? Link::make($participant->telegram)->href("https://t.me/{$participant->telegram}")
75+
: ''
76+
),
77+
78+
TD::make('tracking_number', 'Трек-номер')
79+
->width('20%'),
80+
])
81+
];
82+
}
83+
}

routes/platform.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,9 @@
130130
->breadcrumbs(fn (Trail $trail) => $trail
131131
->parent('platform.challenges')
132132
->push(__('Create'), route('platform.challenges.create')));
133+
134+
Route::screen('/secret-santa', \App\Orchid\Screens\SecretSantaScreen::class)
135+
->name('platform.secret-santa')
136+
->breadcrumbs(fn(Trail $trail) => $trail
137+
->parent('platform.index')
138+
->push('Серетный Санта'));

0 commit comments

Comments
 (0)