Skip to content

Commit d9fbb36

Browse files
Merge branch 'develop' into main
2 parents 6149ff8 + 045dfe0 commit d9fbb36

File tree

54 files changed

+2243
-2998
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2243
-2998
lines changed

app/Concerns/Enums/Comparable.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ trait Comparable
1111
*/
1212
public function is(mixed $enum): bool
1313
{
14+
1415
if ($enum instanceof static) {
1516
return $this->value === $enum->value;
1617
}

app/Enums/GalaProjectStatus.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Enums;
6+
7+
use App\Concerns\Enums\Arrayable;
8+
use App\Concerns\Enums\Comparable;
9+
use App\Concerns\Enums\HasLabel;
10+
11+
enum GalaProjectStatus: string
12+
{
13+
use Arrayable;
14+
use Comparable;
15+
use HasLabel;
16+
17+
case draft = 'draft';
18+
case publish = 'published';
19+
20+
protected function labelKeyPrefix(): ?string
21+
{
22+
return 'project.gala_project_status_ar';
23+
}
24+
}

app/Enums/ProjectArea.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ enum ProjectArea: string
1616

1717
case LOCAL = 'local';
1818
case REGIONAL = 'regional';
19-
case NATIONAL = 'national';
2019

2120
public function labelKeyPrefix(): string
2221
{

app/Filament/Resources/EditionsResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public static function table(Table $table): Table
121121
->searchable()
122122
->sortable(),
123123

124-
Tables\Columns\TextColumn::make('categories')
124+
Tables\Columns\TextColumn::make('editionCategories.name')
125125
->label(__('edition.labels.categories'))
126126
->searchable()
127127
->sortable(),

app/Filament/Resources/EditionsResource/RelationManagers/PrizesRelationManager.php

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
namespace App\Filament\Resources\EditionsResource\RelationManagers;
66

7-
use App\Models\EditionCategories;
87
use Filament\Forms;
98
use Filament\Resources\Form;
109
use Filament\Resources\RelationManagers\RelationManager;
1110
use Filament\Resources\Table;
1211
use Filament\Tables;
12+
use Illuminate\Database\Eloquent\Builder;
1313

1414
class PrizesRelationManager extends RelationManager
1515
{
@@ -20,22 +20,19 @@ class PrizesRelationManager extends RelationManager
2020
public static function form(Form $form): Form
2121
{
2222
return $form
23+
->columns(1)
2324
->schema([
2425
Forms\Components\TextInput::make('name')
25-
->required()
26+
->label(__('edition.labels.prize_name'))
2627
->maxLength(255)
27-
->label(__('edition.labels.prize_name')),
28+
->required(),
2829

2930
Forms\Components\Select::make('edition_categories_id')
30-
->options(
31-
fn (RelationManager $livewire) => EditionCategories::query()
32-
->whereBelongsTo($livewire->ownerRecord)
33-
->get()
34-
->pluck('name', 'id')
35-
)
3631
->label(__('edition.labels.category'))
37-
->columnSpanFull()
38-
->required()
32+
->relationship('editionCategories', 'name', function (Builder $query, self $livewire) {
33+
$query->whereBelongsTo($livewire->ownerRecord);
34+
})
35+
->searchable()
3936
->preload(),
4037
]);
4138
}
@@ -49,11 +46,8 @@ public static function table(Table $table): Table
4946
->searchable()
5047
->sortable(),
5148

52-
Tables\Columns\TextColumn::make('edition_categories_id')
49+
Tables\Columns\TextColumn::make('editionCategories.name')
5350
->label(__('edition.labels.category'))
54-
->formatStateUsing(
55-
fn ($state, $record) => $record->editionCategories()->getParent()->name
56-
)
5751
->searchable()
5852
->sortable(),
5953
])

app/Filament/Resources/GalaProjectResource.php

Lines changed: 53 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44

55
namespace App\Filament\Resources;
66

7+
use App\Enums\GalaProjectStatus;
78
use App\Enums\OrganizationType;
89
use App\Enums\ProjectArea;
10+
use App\Filament\Forms\Components\Value;
911
use App\Filament\Resources\GalaProjectResource\Pages;
10-
use App\Models\Edition;
12+
use App\Filament\Resources\GalaProjectResource\RelationManagers\PrizesRelationManager;
13+
use App\Forms\Components\Link;
1114
use App\Models\GalaProject;
1215
use Filament\Forms\Components\DatePicker;
1316
use Filament\Forms\Components\Select;
17+
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
1418
use Filament\Forms\Components\Textarea;
1519
use Filament\Forms\Components\TextInput;
1620
use Filament\Forms\Components\Toggle;
@@ -44,15 +48,26 @@ public static function getPluralLabel(): string
4448
return __('edition.project.label.plural');
4549
}
4650

47-
public static function getEloquentQuery(): Builder
48-
{
49-
return parent::getEloquentQuery()->with(['gala']);
50-
}
51+
// public static function getEloquentQuery(): Builder
52+
// {
53+
// return parent::getEloquentQuery()->with(['gala']);
54+
// }
5155

5256
public static function form(Form $form): Form
5357
{
5458
return $form
5559
->schema([
60+
Value::make('created_at')
61+
->label(__('edition.labels.created_at'))
62+
->inlineLabel()
63+
->withTime(),
64+
65+
Link::make('organizatii')
66+
->type('organization')
67+
->label(__('organization.label.singular'))
68+
->inlineLabel()
69+
->columnSpanFull(),
70+
5671
Select::make('gala')
5772
->label(__('edition.labels.gala'))
5873
->relationship(
@@ -113,6 +128,15 @@ function (Builder $query, GalaProject $record) {
113128
->inlineLabel()
114129
->required(),
115130

131+
SpatieMediaLibraryFileUpload::make('regionalProjectFiles')
132+
->label(__('project.labels.gallery'))
133+
->collection('regionalProjectFiles')
134+
->inlineLabel()
135+
->disk(config('filesystems.default_public'))
136+
->image()
137+
->multiple()
138+
->maxFiles(20),
139+
116140
Toggle::make('youth')
117141
->label(__('edition.labels.youth_project'))
118142
->inlineLabel()
@@ -198,33 +222,33 @@ function (Builder $query, GalaProject $record) {
198222

199223
public static function table(Table $table): Table
200224
{
201-
$editions = Edition::all();
202-
203225
return $table
204226
->columns([
205-
Tables\Columns\TextColumn::make('title')
227+
Tables\Columns\TextColumn::make('id')
228+
->label(__('edition.labels.id'))
229+
->searchable()
230+
->sortable(),
231+
232+
Tables\Columns\TextColumn::make('name')
206233
->label(__('edition.project.label.plural'))
207234
->searchable()
235+
->wrap()
208236
->sortable(),
209237

210238
Tables\Columns\TextColumn::make('categories.name')
211239
->label(__('edition.labels.category'))
212240
->searchable()
213-
->sortable(),
241+
->wrap(),
214242

215243
Tables\Columns\TextColumn::make('youth')
216244
->label(__('edition.labels.youth'))
217245
->formatStateUsing(fn ($state) => $state ? __('field.boolean.true') : __('field.boolean.false'))
218246
->searchable()
219247
->sortable(),
220248

221-
Tables\Columns\TextColumn::make('gala.edition.title')
222-
->label(__('edition.label.singular'))
223-
->searchable()
224-
->sortable(),
225-
226249
Tables\Columns\TextColumn::make('gala.title')
227250
->label(__('edition.labels.gala'))
251+
->description(fn ($record) => $record->gala->edition->title)
228252
->searchable()
229253
->sortable(),
230254

@@ -233,6 +257,11 @@ public static function table(Table $table): Table
233257
->searchable()
234258
->sortable(),
235259

260+
Tables\Columns\TextColumn::make('created_at')
261+
->label(__('edition.labels.created_at'))
262+
->searchable()
263+
->sortable(),
264+
236265
Tables\Columns\TextColumn::make('eligible')
237266
->label(__('edition.labels.eligible'))
238267
->formatStateUsing(fn ($state) => ! isset($state) ? '-' : ($state ? __('field.boolean.true') : __('field.boolean.false')))
@@ -248,12 +277,7 @@ public static function table(Table $table): Table
248277
->filters([
249278
SelectFilter::make('edition_id')
250279
->label(__('edition.label.singular'))
251-
->options($editions->pluck('title', 'id')->toArray())
252-
// ->query(
253-
// function ($query, $values) {
254-
// dd($values);
255-
// }
256-
// )
280+
->relationship('edition', 'title')
257281
->multiple(),
258282

259283
SelectFilter::make('galas')
@@ -280,23 +304,27 @@ public static function table(Table $table): Table
280304
]),
281305
])
282306
->bulkActions([
283-
Tables\Actions\DeleteBulkAction::make(),
284-
]);
307+
//
308+
])
309+
->defaultSort('id', 'desc');
285310
}
286311

287312
public static function getRelations(): array
288313
{
289314
return [
290-
//
315+
PrizesRelationManager::class,
291316
];
292317
}
293318

319+
public static function getEloquentQuery(): Builder
320+
{
321+
return parent::getEloquentQuery()->where('status', GalaProjectStatus::publish);
322+
}
323+
294324
public static function getPages(): array
295325
{
296326
return [
297327
'index' => Pages\ListGalaProjects::route('/'),
298-
'create' => Pages\CreateGalaProject::route('/create'),
299-
'edit' => Pages\EditGalaProject::route('/{record}/edit'),
300328
'view' => Pages\ViewGalaProject::route('/{record}'),
301329
];
302330
}

app/Filament/Resources/GalaProjectResource/Actions/Page/AddToShortListAction.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace App\Filament\Resources\GalaProjectResource\Actions\Page;
66

7+
use App\Models\GalaProject;
78
use Filament\Pages\Actions\Action;
89

910
class AddToShortListAction extends Action
@@ -19,8 +20,16 @@ protected function setUp(): void
1920

2021
$this->label(__('edition.actions.add-to-short-list'));
2122

22-
$this->action(function () {
23-
$this->getRecord()->addToShortList();
23+
$this->color('success');
24+
25+
$this->icon('heroicon-s-plus-circle');
26+
27+
$this->outlined();
28+
29+
$this->action(function (GalaProject $record) {
30+
$record->addToShortList();
2431
});
32+
33+
$this->hidden(fn (GalaProject $record) => $record->short_list === true);
2534
}
2635
}

app/Filament/Resources/GalaProjectResource/Actions/Page/MarkAsEligibleAction.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace App\Filament\Resources\GalaProjectResource\Actions\Page;
66

7+
use App\Models\GalaProject;
78
use Filament\Pages\Actions\Action;
89

910
class MarkAsEligibleAction extends Action
@@ -19,8 +20,14 @@ protected function setUp(): void
1920

2021
$this->label(__('edition.actions.mark-as-eligible'));
2122

22-
$this->action(function () {
23-
$this->getRecord()->markAsEligible();
23+
$this->color('success');
24+
25+
$this->icon('heroicon-o-check-circle');
26+
27+
$this->action(function (GalaProject $record) {
28+
$record->markAsEligible();
2429
});
30+
31+
$this->hidden(fn (GalaProject $record) => $record->eligible === true);
2532
}
2633
}

app/Filament/Resources/GalaProjectResource/Actions/Page/MarkAsIneligibleAction.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace App\Filament\Resources\GalaProjectResource\Actions\Page;
66

7+
use App\Models\GalaProject;
78
use Filament\Pages\Actions\Action;
89

910
class MarkAsIneligibleAction extends Action
@@ -19,8 +20,14 @@ protected function setUp(): void
1920

2021
$this->label(__('edition.actions.mark-as-ineligible'));
2122

22-
$this->action(function () {
23-
$this->getRecord()->markAsIneligible();
23+
$this->color('danger');
24+
25+
$this->icon('heroicon-o-x-circle');
26+
27+
$this->action(function (GalaProject $record) {
28+
$record->markAsIneligible();
2429
});
30+
31+
$this->hidden(fn (GalaProject $record) => $record->eligible === false);
2532
}
2633
}

app/Filament/Resources/GalaProjectResource/Actions/Page/RemoveFromShortListAction.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace App\Filament\Resources\GalaProjectResource\Actions\Page;
66

7+
use App\Models\GalaProject;
78
use Filament\Pages\Actions\Action;
89

910
class RemoveFromShortListAction extends Action
@@ -19,8 +20,16 @@ protected function setUp(): void
1920

2021
$this->label(__('edition.actions.remove-from-short-list'));
2122

22-
$this->action(function () {
23-
$this->getRecord()->removeFromShortList();
23+
$this->color('danger');
24+
25+
$this->icon('heroicon-s-minus-circle');
26+
27+
$this->outlined();
28+
29+
$this->action(function (GalaProject $record) {
30+
$record->removeFromShortList();
2431
});
32+
33+
$this->hidden(fn (GalaProject $record) => $record->short_list === false);
2534
}
2635
}

0 commit comments

Comments
 (0)