-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Editions * Seeder * CR * gala projects * wip * gala projects * min * cleanup && refactoring * wip * cleanup Gala projects * cleanup Gala projects * wip * wip * fix import * wip on gala * fix * wip --------- Co-authored-by: Lupu Gheorghe <[email protected]>
- Loading branch information
1 parent
e4839b8
commit ff9c6e3
Showing
70 changed files
with
3,407 additions
and
1,581 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Concerns; | ||
|
||
use App\Models\Edition; | ||
use Illuminate\Database\Eloquent\Relations\BelongsTo; | ||
|
||
trait BelongsToEdition | ||
{ | ||
public function edition(): BelongsTo | ||
{ | ||
return $this->belongsTo(Edition::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Enums; | ||
|
||
use App\Concerns\Enums\Arrayable; | ||
use App\Concerns\Enums\Comparable; | ||
use App\Concerns\Enums\HasLabel; | ||
|
||
enum OrganizationType: string | ||
{ | ||
use Arrayable; | ||
use Comparable; | ||
use HasLabel; | ||
|
||
case LITTLE = 'little'; | ||
case BIG = 'big'; | ||
|
||
public function labelKeyPrefix(): string | ||
{ | ||
return 'edition.labels.organization_types'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Enums; | ||
|
||
use App\Concerns\Enums\Arrayable; | ||
use App\Concerns\Enums\Comparable; | ||
use App\Concerns\Enums\HasLabel; | ||
|
||
enum ProjectArea: string | ||
{ | ||
use Arrayable; | ||
use Comparable; | ||
use HasLabel; | ||
|
||
case LOCAL = 'local'; | ||
case REGIONAL = 'regional'; | ||
case NATIONAL = 'national'; | ||
|
||
public function labelKeyPrefix(): string | ||
{ | ||
return 'edition.labels.areas'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Resources; | ||
|
||
use App\Filament\Resources\EditionsResource\Pages\CreateEditions; | ||
use App\Filament\Resources\EditionsResource\Pages\EditEditions; | ||
use App\Filament\Resources\EditionsResource\Pages\ListEditions; | ||
use App\Filament\Resources\EditionsResource\RelationManagers\CategoryRelationManager; | ||
use App\Filament\Resources\EditionsResource\RelationManagers\FaqRelationManager; | ||
use App\Filament\Resources\EditionsResource\RelationManagers\GalesRelationManager; | ||
use App\Filament\Resources\EditionsResource\RelationManagers\PrizesRelationManager; | ||
use App\Models\ArticleCategory; | ||
use App\Models\Edition; | ||
use Filament\Forms; | ||
use Filament\Forms\Components\DatePicker; | ||
use Filament\Forms\Components\Fieldset; | ||
use Filament\Forms\Components\Select; | ||
use Filament\Forms\Components\SpatieMediaLibraryFileUpload; | ||
use Filament\Forms\Components\Textarea; | ||
use Filament\Forms\Components\TextInput; | ||
use Filament\Resources\Form; | ||
use Filament\Resources\Resource; | ||
use Filament\Resources\Table; | ||
use Filament\Tables; | ||
use Illuminate\Database\Eloquent\Builder; | ||
|
||
class EditionsResource extends Resource | ||
{ | ||
protected static ?string $model = Edition::class; | ||
|
||
protected static ?int $navigationSort = 1; | ||
|
||
protected static ?string $navigationIcon = 'heroicon-o-collection'; | ||
|
||
protected static function getNavigationGroup(): ?string | ||
{ | ||
return __('navigation.group.gala'); | ||
} | ||
|
||
public static function getModelLabel(): string | ||
{ | ||
return __('edition.label.singular'); | ||
} | ||
|
||
public static function getPluralLabel(): string | ||
{ | ||
return __('edition.label.plural'); | ||
} | ||
|
||
public static function getEloquentQuery(): Builder | ||
{ | ||
return parent::getEloquentQuery()->with(['editionCategories']); | ||
} | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
Fieldset::make(__('edition.label.singular')) | ||
->columns(1) | ||
->schema([ | ||
TextInput::make('title') | ||
->label(__('edition.labels.title')) | ||
->required() | ||
->maxLength(255), | ||
|
||
Textarea::make('short_description') | ||
->label(__('edition.labels.short_description')) | ||
->required() | ||
->maxLength(65535), | ||
|
||
SpatieMediaLibraryFileUpload::make('rule') | ||
->label(__('edition.labels.rule')) | ||
->disk(config('filesystems.default_public')) | ||
->required() | ||
->maxFiles(1) | ||
->columnSpanFull(), | ||
|
||
Select::make('rule_page') | ||
->relationship('page', 'title') | ||
->label(__('edition.labels.rule_page')) | ||
->preload() | ||
->required(), | ||
|
||
Select::make('article_category_id') | ||
->relationship('articleCategory', 'name') | ||
->options(ArticleCategory::all() | ||
->pluck('name', 'id')) | ||
->label(__('edition.labels.edition_category')) | ||
->preload() | ||
->required(), | ||
|
||
Forms\Components\Grid::make() | ||
->schema([ | ||
DatePicker::make('start_date') | ||
->label(__('edition.labels.start')) | ||
->placeholder( | ||
fn ($state): string => today() | ||
->toFormattedDate() | ||
), | ||
|
||
DatePicker::make('end_date') | ||
->label(__('edition.labels.end')) | ||
->placeholder( | ||
fn ($state): string => today() | ||
->toFormattedDate() | ||
), | ||
]), | ||
]), | ||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
Tables\Columns\TextColumn::make('title') | ||
->label(__('edition.labels.name')) | ||
->searchable() | ||
->sortable(), | ||
|
||
Tables\Columns\TextColumn::make('categories') | ||
->label(__('edition.labels.categories')) | ||
->searchable() | ||
->sortable(), | ||
|
||
Tables\Columns\TextColumn::make('start_date') | ||
->label(__('edition.labels.start_date')) | ||
->searchable() | ||
->sortable(), | ||
|
||
Tables\Columns\TextColumn::make('end_date') | ||
->label(__('edition.labels.end_date')) | ||
->searchable() | ||
->sortable(), | ||
]) | ||
->filters([ | ||
// | ||
]) | ||
->actions([ | ||
Tables\Actions\EditAction::make(), | ||
]) | ||
->bulkActions([ | ||
Tables\Actions\DeleteBulkAction::make(), | ||
]); | ||
} | ||
|
||
public static function getRelations(): array | ||
{ | ||
return [ | ||
CategoryRelationManager::class, | ||
FaqRelationManager::class, | ||
GalesRelationManager::class, | ||
PrizesRelationManager::class, | ||
|
||
]; | ||
} | ||
|
||
public static function getPages(): array | ||
{ | ||
return [ | ||
'index' => ListEditions::route('/'), | ||
'create' => CreateEditions::route('/create'), | ||
'edit' => EditEditions::route('/{record}/edit'), | ||
]; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
app/Filament/Resources/EditionsResource/Pages/CreateEditions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Resources\EditionsResource\Pages; | ||
|
||
use App\Filament\Resources\EditionsResource; | ||
use Filament\Resources\Pages\CreateRecord; | ||
|
||
class CreateEditions extends CreateRecord | ||
{ | ||
protected static string $resource = EditionsResource::class; | ||
} |
26 changes: 26 additions & 0 deletions
26
app/Filament/Resources/EditionsResource/Pages/EditEditions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Resources\EditionsResource\Pages; | ||
|
||
use App\Filament\Resources\EditionsResource; | ||
use Filament\Pages\Actions; | ||
use Filament\Resources\Pages\EditRecord; | ||
|
||
class EditEditions extends EditRecord | ||
{ | ||
protected static string $resource = EditionsResource::class; | ||
|
||
protected function getActions(): array | ||
{ | ||
return [ | ||
Actions\DeleteAction::make(), | ||
]; | ||
} | ||
|
||
public function hasCombinedRelationManagerTabsWithForm(): bool | ||
{ | ||
return true; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
app/Filament/Resources/EditionsResource/Pages/ListEditions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Resources\EditionsResource\Pages; | ||
|
||
use App\Filament\Resources\EditionsResource; | ||
use Filament\Pages\Actions; | ||
use Filament\Resources\Pages\ListRecords; | ||
|
||
class ListEditions extends ListRecords | ||
{ | ||
protected static string $resource = EditionsResource::class; | ||
|
||
protected function getActions(): array | ||
{ | ||
return [ | ||
Actions\CreateAction::make(), | ||
]; | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
app/Filament/Resources/EditionsResource/RelationManagers/CategoryRelationManager.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Filament\Resources\EditionsResource\RelationManagers; | ||
|
||
use Filament\Forms; | ||
use Filament\Resources\Form; | ||
use Filament\Resources\RelationManagers\RelationManager; | ||
use Filament\Resources\Table; | ||
use Filament\Tables; | ||
|
||
class CategoryRelationManager extends RelationManager | ||
{ | ||
protected static string $relationship = 'editionCategories'; | ||
|
||
protected static ?string $recordTitleAttribute = 'Category'; | ||
|
||
public static function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
Forms\Components\TextInput::make('name') | ||
->label(__('edition.labels.category')) | ||
->required() | ||
->maxLength(255), | ||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
Tables\Columns\TextColumn::make('name') | ||
->label(__('edition.labels.categories')) | ||
->searchable() | ||
->sortable(), | ||
]) | ||
->filters([ | ||
// | ||
]) | ||
->headerActions([ | ||
Tables\Actions\CreateAction::make() | ||
->label(__('edition.labels.add_category')), | ||
]) | ||
->actions([ | ||
Tables\Actions\EditAction::make(), | ||
Tables\Actions\DeleteAction::make(), | ||
]) | ||
->bulkActions([ | ||
Tables\Actions\DeleteBulkAction::make(), | ||
]); | ||
} | ||
|
||
public static function getTitle(): string | ||
{ | ||
return __('edition.labels.categories_tab'); | ||
} | ||
} |
Oops, something went wrong.