Refactor navigation icon declarations in various resources for consistency; enhance Group model with new relationships and fillable properties; update Hotel and Pilgrim models with fillable attributes; improve table configurations across resources.
This commit is contained in:
11
app/Filament/Resources/Programs/Pages/CreateProgram.php
Normal file
11
app/Filament/Resources/Programs/Pages/CreateProgram.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Programs\Pages;
|
||||
|
||||
use App\Filament\Resources\Programs\ProgramResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateProgram extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ProgramResource::class;
|
||||
}
|
||||
21
app/Filament/Resources/Programs/Pages/EditProgram.php
Normal file
21
app/Filament/Resources/Programs/Pages/EditProgram.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Programs\Pages;
|
||||
|
||||
use App\Filament\Resources\Programs\ProgramResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditProgram extends EditRecord
|
||||
{
|
||||
protected static string $resource = ProgramResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ViewAction::make(),
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Filament/Resources/Programs/Pages/ListPrograms.php
Normal file
19
app/Filament/Resources/Programs/Pages/ListPrograms.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Programs\Pages;
|
||||
|
||||
use App\Filament\Resources\Programs\ProgramResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListPrograms extends ListRecords
|
||||
{
|
||||
protected static string $resource = ProgramResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Filament/Resources/Programs/Pages/ViewProgram.php
Normal file
19
app/Filament/Resources/Programs/Pages/ViewProgram.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Programs\Pages;
|
||||
|
||||
use App\Filament\Resources\Programs\ProgramResource;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewProgram extends ViewRecord
|
||||
{
|
||||
protected static string $resource = ProgramResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
46
app/Filament/Resources/Programs/ProgramResource.php
Normal file
46
app/Filament/Resources/Programs/ProgramResource.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Programs;
|
||||
|
||||
use App\Filament\Resources\Programs\Schemas\ProgramForm;
|
||||
use App\Filament\Resources\Programs\Tables\ProgramsTable;
|
||||
use App\Models\Program;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ProgramResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Program::class;
|
||||
|
||||
protected static ?string $navigationLabel = 'Programmalar';
|
||||
|
||||
protected static ?string $pluralLabel = 'Programmalar';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?int $navigationSort = 7;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-calendar-days';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return ProgramForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return ProgramsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListPrograms::route('/'),
|
||||
'create' => Pages\CreateProgram::route('/create'),
|
||||
'edit' => Pages\EditProgram::route('/{record}/edit'),
|
||||
'view' => Pages\ViewProgram::route('/{record}'),
|
||||
];
|
||||
}
|
||||
}
|
||||
51
app/Filament/Resources/Programs/Schemas/ProgramForm.php
Normal file
51
app/Filament/Resources/Programs/Schemas/ProgramForm.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Programs\Schemas;
|
||||
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\TimePicker;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class ProgramForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Select::make('group_id')
|
||||
->relationship('group', 'name')
|
||||
->label('Topar')
|
||||
->required(),
|
||||
Repeater::make('days')
|
||||
->label('Günler')
|
||||
->itemLabel(fn (array $state): ?string => ($state['day_number'] ?? '').'-nji gün')
|
||||
->schema([
|
||||
TextInput::make('day_number')
|
||||
->numeric()
|
||||
->required()
|
||||
->label('Günüň belgisi'),
|
||||
Repeater::make('actions')
|
||||
->label('Actionlar')
|
||||
->schema([
|
||||
TextInput::make('title')
|
||||
->label('Ady')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Textarea::make('description')
|
||||
->label('Düşündirişi')
|
||||
->columnSpanFull(),
|
||||
TimePicker::make('time')
|
||||
->label('Wagty'),
|
||||
TextInput::make('icon')
|
||||
->label('Ikony')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
])
|
||||
->columns(2),
|
||||
])->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
21
app/Filament/Resources/Programs/Schemas/ProgramInfolist.php
Normal file
21
app/Filament/Resources/Programs/Schemas/ProgramInfolist.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Programs\Schemas;
|
||||
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class ProgramInfolist
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextEntry::make('group.id'),
|
||||
TextEntry::make('created_at')
|
||||
->dateTime(),
|
||||
TextEntry::make('updated_at')
|
||||
->dateTime(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
47
app/Filament/Resources/Programs/Tables/ProgramsTable.php
Normal file
47
app/Filament/Resources/Programs/Tables/ProgramsTable.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Programs\Tables;
|
||||
|
||||
use Filament\Tables\Actions\BulkActionGroup;
|
||||
use Filament\Tables\Actions\DeleteBulkAction;
|
||||
use Filament\Tables\Actions\EditAction;
|
||||
use Filament\Tables\Actions\ViewAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ProgramsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('group.name')
|
||||
->label('Topar')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('days')
|
||||
->label('Gün sany')
|
||||
->getStateUsing(fn ($record) => count($record->days).' gün')
|
||||
->sortable(),
|
||||
TextColumn::make('created_at')
|
||||
->label('Döredilen wagty')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->label('Üýtgedilen wagty')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->actions([
|
||||
ViewAction::make(),
|
||||
EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user