diff --git a/app/Filament/Resources/Pilgrims/PilgrimResource.php b/app/Filament/Resources/Pilgrims/PilgrimResource.php index 36da219..b1bd46c 100644 --- a/app/Filament/Resources/Pilgrims/PilgrimResource.php +++ b/app/Filament/Resources/Pilgrims/PilgrimResource.php @@ -28,19 +28,11 @@ class PilgrimResource extends Resource protected static ?string $pluralLabel = 'Zyýaratçylar'; - /** - * @param Schema $schema - * @return Schema - */ public static function form(Schema $schema): Schema { return PilgrimForm::configure($schema); } - /** - * @param Table $table - * @return Table - */ public static function table(Table $table): Table { return PilgrimsTable::configure($table); @@ -56,7 +48,7 @@ class PilgrimResource extends Resource ]; } - /** + /** * @return array */ public static function getPages(): array diff --git a/app/Filament/Resources/Pilgrims/Schemas/PilgrimForm.php b/app/Filament/Resources/Pilgrims/Schemas/PilgrimForm.php index d111583..5a95840 100644 --- a/app/Filament/Resources/Pilgrims/Schemas/PilgrimForm.php +++ b/app/Filament/Resources/Pilgrims/Schemas/PilgrimForm.php @@ -10,10 +10,6 @@ use Filament\Schemas\Schema; class PilgrimForm { - /** - * @param Schema $schema - * @return Schema - */ public static function configure(Schema $schema): Schema { return $schema diff --git a/app/Filament/Resources/Programs/Pages/ViewProgram.php b/app/Filament/Resources/Programs/Pages/ViewProgram.php index dddbb53..22930a8 100644 --- a/app/Filament/Resources/Programs/Pages/ViewProgram.php +++ b/app/Filament/Resources/Programs/Pages/ViewProgram.php @@ -3,6 +3,7 @@ namespace App\Filament\Resources\Programs\Pages; use App\Filament\Resources\Programs\ProgramResource; +use Filament\Actions\DeleteAction; use Filament\Actions\EditAction; use Filament\Resources\Pages\ViewRecord; @@ -14,6 +15,7 @@ class ViewProgram extends ViewRecord { return [ EditAction::make(), + DeleteAction::make(), ]; } } diff --git a/app/Filament/Resources/Programs/ProgramResource.php b/app/Filament/Resources/Programs/ProgramResource.php index ef1308d..dde2587 100644 --- a/app/Filament/Resources/Programs/ProgramResource.php +++ b/app/Filament/Resources/Programs/ProgramResource.php @@ -2,12 +2,20 @@ 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\Actions\BulkActionGroup; +use Filament\Actions\DeleteAction; +use Filament\Actions\DeleteBulkAction; +use Filament\Actions\EditAction; +use Filament\Actions\ViewAction; +use Filament\Forms\Components\DatePicker; +use Filament\Forms\Components\Repeater; +use Filament\Forms\Components\Select; +use Filament\Forms\Components\TextInput; use Filament\Resources\Resource; use Filament\Schemas\Schema; +use Filament\Tables\Columns\TextColumn; use Filament\Tables\Table; class ProgramResource extends Resource @@ -26,12 +34,73 @@ class ProgramResource extends Resource public static function form(Schema $schema): Schema { - return ProgramForm::configure($schema); + return $schema + ->components([ + TextInput::make('name') + ->label('Programmanyň ady') + ->required() + ->default('Adaty') + ->columnSpanFull(), + + Select::make('group_id') + ->relationship('group', 'id') + ->label('Topar') + ->required() + ->columnSpanFull(), + + Repeater::make('days') + ->label('Günler') + ->schema([ + DatePicker::make('day') + ->label('Gün (dd.mm.yyyy)') + ->native(false) + ->required(), + Repeater::make('activities') + ->label('Işler') + ->schema([ + TextInput::make('time')->label('Wagty'), + TextInput::make('title')->label('Ady')->required(), + TextInput::make('description')->label('Düşündirişi'), + + Select::make('iconSet')->label('Ikon toplumy')->options([ + 'FontAwesome' => 'FontAwesome', + 'FontAwesome5' => 'FontAwesome5', + ])->default('FontAwesome5')->required(), + + TextInput::make('iconName')->label('Ikon ady')->required(), + Select::make('transport')->label('Ulag')->options([ + 'bus' => 'Bus', + 'car' => 'Car', + 'train' => 'Train', + 'plane' => 'Plane', + ])->default('bus')->required(), + ]) + ->columns(2), + ]) + ->columnSpanFull(), + ]); } public static function table(Table $table): Table { - return ProgramsTable::configure($table); + return $table + ->columns([ + TextColumn::make('name')->label('Programmanyň ady')->searchable(), + TextColumn::make('group.name')->label('Topar')->searchable(), + ]) + ->filters([ + // + ]) + ->recordActions([ + EditAction::make(), + ViewAction::make(), + DeleteAction::make(), + ]) + ->toolbarActions([ + BulkActionGroup::make([ + DeleteBulkAction::make(), + ]), + ]); } public static function getPages(): array @@ -43,4 +112,37 @@ class ProgramResource extends Resource 'view' => Pages\ViewProgram::route('/{record}'), ]; } + + public static function mutateFormDataBeforeFill(array $data): array + { + if (! is_array($data['days'])) { + $data['days'] = []; + } else { + $days = []; + foreach ($data['days'] as $date => $activities) { + $days[] = [ + 'day' => $date, + 'activities' => $activities, + ]; + } + $data['days'] = $days; + } + + return $data; + } + + public static function mutateFormDataBeforeSave(array $data): array + { + $days = []; + if (is_array($data['days'])) { + foreach ($data['days'] as $day) { + if (isset($day['day']) && isset($day['activities'])) { + $days[date('d.m.Y', strtotime($day['day']))] = $day['activities']; + } + } + } + $data['days'] = $days; + + return $data; + } } diff --git a/app/Filament/Resources/Programs/Schemas/ProgramForm.php b/app/Filament/Resources/Programs/Schemas/ProgramForm.php deleted file mode 100644 index 9b13f17..0000000 --- a/app/Filament/Resources/Programs/Schemas/ProgramForm.php +++ /dev/null @@ -1,51 +0,0 @@ -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(), - ]); - } -} diff --git a/app/Filament/Resources/Programs/Tables/ProgramsTable.php b/app/Filament/Resources/Programs/Tables/ProgramsTable.php deleted file mode 100644 index d08cb43..0000000 --- a/app/Filament/Resources/Programs/Tables/ProgramsTable.php +++ /dev/null @@ -1,47 +0,0 @@ -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(), - ]), - ]); - } -} diff --git a/app/Filament/Resources/Users/UserResource.php b/app/Filament/Resources/Users/UserResource.php index d99e7f3..bb01302 100644 --- a/app/Filament/Resources/Users/UserResource.php +++ b/app/Filament/Resources/Users/UserResource.php @@ -2,7 +2,6 @@ namespace App\Filament\Resources\Users; -use UnitEnum; use App\Filament\Resources\Users\Pages\CreateUser; use App\Filament\Resources\Users\Pages\EditUser; use App\Filament\Resources\Users\Pages\ListUsers; @@ -13,12 +12,13 @@ use BackedEnum; use Filament\Resources\Resource; use Filament\Schemas\Schema; use Filament\Tables\Table; +use UnitEnum; class UserResource extends Resource { protected static ?string $model = User::class; - protected static string | UnitEnum | null $navigationGroup = 'Sazlamalar'; + protected static string|UnitEnum|null $navigationGroup = 'Sazlamalar'; protected static ?string $navigationLabel = 'Ulanyjylar'; @@ -30,7 +30,7 @@ class UserResource extends Resource protected static ?int $navigationSort = 1; - protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-user-group'; + protected static string|BackedEnum|null $navigationIcon = 'heroicon-o-user-group'; public static function form(Schema $schema): Schema { diff --git a/app/Models/Program.php b/app/Models/Program.php index 64cb199..21dceca 100644 --- a/app/Models/Program.php +++ b/app/Models/Program.php @@ -12,6 +12,7 @@ class Program extends Model use HasFactory; protected $fillable = [ + 'name', 'group_id', 'days', ]; diff --git a/database/migrations/2025_09_02_195635_create_programs_table.php b/database/migrations/2025_09_02_195635_create_programs_table.php index 2db202e..ed3ddd3 100644 --- a/database/migrations/2025_09_02_195635_create_programs_table.php +++ b/database/migrations/2025_09_02_195635_create_programs_table.php @@ -13,6 +13,7 @@ return new class extends Migration { Schema::create('programs', function (Blueprint $table) { $table->id(); + $table->string('name'); $table->foreignId('group_id')->constrained()->cascadeOnDelete(); $table->json('days'); $table->timestamps(); diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 7335bd2..799ac33 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -14,6 +14,8 @@ class DatabaseSeeder extends Seeder $this->call([ UserTableSeeder::class, TeacherTableSeeder::class, + GroupSeeder::class, + ProgramSeeder::class, ]); } } diff --git a/database/seeders/GroupSeeder.php b/database/seeders/GroupSeeder.php new file mode 100644 index 0000000..ef923dc --- /dev/null +++ b/database/seeders/GroupSeeder.php @@ -0,0 +1,22 @@ + Teacher::where('name', 'Nurmuhammet')->first()->id, + 'start_date' => '2025-09-19', + 'end_date' => '2025-10-03', + ]); + } +} diff --git a/database/seeders/ProgramSeeder.php b/database/seeders/ProgramSeeder.php new file mode 100644 index 0000000..30b200e --- /dev/null +++ b/database/seeders/ProgramSeeder.php @@ -0,0 +1,217 @@ + [ + [ + 'time' => '05:10', + 'title' => 'Jidda gonmak', + 'description' => 'Jidda aýraportynda zyýarata gelenleri garşy almak', + 'iconSet' => 'FontAwesome', + 'iconName' => 'plane', + 'transport' => 'plane', + ], + [ + 'time' => '', + 'title' => 'Medinä gitmek', + 'description' => 'Simkart almak we awtobusa ýerleşmek', + 'iconSet' => 'FontAwesome', + 'iconName' => 'bus', + 'transport' => 'bus', + ], + [ + 'time' => '', + 'title' => 'Otele ýerleşmek', + 'description' => 'Otaglara ýerleşmek', + 'iconSet' => 'FontAwesome', + 'iconName' => 'hotel', + 'transport' => 'bus', + ], + [ + 'time' => 'günüň dowamynda', + 'title' => 'Pygamberimiziň (saw) metjidi', + 'description' => 'Pygamberimiziň (saw) metjidine zyýarata gitmek', + 'iconSet' => 'FontAwesome5', + 'iconName' => 'mosque', + 'transport' => 'bus', + ], + ], + '20.09.2025' => [ + [ + 'time' => 'günüň dowamynda', + 'title' => 'Pygamberimiziň (saw) metjidi', + 'description' => 'Pygamberimiziň (saw) metjidine zyýarata gitmek', + 'iconSet' => 'FontAwesome5', + 'iconName' => 'mosque', + 'transport' => 'bus', + ], + ], + '21.09.2025' => [ + [ + 'time' => '07:00', + 'title' => 'Zyýarat ýerleri', + 'description' => 'Medine şäherindäki ähli zyýarat ýerlerine zyýarat etmek, Kuba metjidi, Kyblateýin metjidi, Uhud daglary, Hurma baglary', + 'iconSet' => 'FontAwesome5', + 'iconName' => 'gopuram', + 'transport' => 'bus', + ], + [ + 'time' => '', + 'title' => 'Kuran zawody', + 'description' => 'Eger açyk bolup mümkinçilik bolsa', + 'iconSet' => 'FontAwesome5', + 'iconName' => 'quran', + 'transport' => 'bus', + ], + [ + 'time' => 'günüň dowamynda', + 'title' => 'Pygamberimiziň (saw) metjidi', + 'description' => '', + 'iconSet' => 'FontAwesome5', + 'iconName' => 'mosque', + 'transport' => 'bus', + ], + ], + '22.09.2025' => [ + [ + 'time' => '', + 'title' => 'Myhmanhanadan çykmak', + 'description' => '', + 'iconSet' => 'FontAwesome', + 'iconName' => 'hotel', + 'transport' => 'bus', + ], + [ + 'time' => '14:00', + 'title' => 'Mekkä gitmek (Umra)', + 'description' => '', + 'iconSet' => 'FontAwesome', + 'iconName' => 'bus', + 'transport' => 'bus', + ], + [ + 'time' => '', + 'title' => 'Best Western oteline ýerleşmek', + 'description' => 'Otaglara ýerleşmek', + 'iconSet' => 'FontAwesome', + 'iconName' => 'hotel', + 'transport' => 'bus', + ], + [ + 'time' => 'günüň dowamynda', + 'title' => 'Umra zyýaraty', + 'description' => '', + 'iconSet' => 'FontAwesome5', + 'iconName' => 'kaaba', + 'transport' => 'bus', + ], + ], + '24.09.2025' => [ + [ + 'time' => '15:00', + 'title' => 'Optom bazary', + 'description' => 'Kakiyya Bazaryna gitmek', + 'iconSet' => 'FontAwesome', + 'iconName' => 'shopping-bag', + 'transport' => 'bus', + ], + ], + '25.09.2025' => [ + [ + 'time' => '07:00', + 'title' => 'Aýşa metjidi (Umra)', + 'description' => 'Aýşa enemiziň metjidine gitmek', + 'iconSet' => 'FontAwesome5', + 'iconName' => 'mosque', + 'transport' => 'bus', + ], + ], + '26.09.2025' => [ + [ + 'time' => 'günüň dowamynda', + 'title' => 'Juma', + 'description' => '', + 'iconSet' => 'FontAwesome5', + 'iconName' => 'mosque', + 'transport' => 'bus', + ], + ], + '27.09.2025' => [ + [ + 'time' => '07:00', + 'title' => 'Gyzyl deňizi we Howa enemize zyýarat', + 'description' => '', + 'iconSet' => 'FontAwesome5', + 'iconName' => 'water', + 'transport' => 'bus', + ], + ], + '28.09.2025' => [ + [ + 'time' => '07:00', + 'title' => 'Mekke zyýaratlary', + 'description' => 'Arafat dagy, Nur dagy, Sawr dagy, Mina-Muzdalifa daglaryna zyýarat etmek', + 'iconSet' => 'FontAwesome5', + 'iconName' => 'gopuram', + 'transport' => 'bus', + ], + ], + '29.09.2025' => [ + [ + 'time' => '07:00', + 'title' => 'Taif şäheri (Umra)', + 'description' => '', + 'iconSet' => 'FontAwesome5', + 'iconName' => 'mountain', + 'transport' => 'bus', + ], + ], + '01.10.2025' => [ + [ + 'time' => '23:00', + 'title' => 'Nur dagyna çykmak', + 'description' => '', + 'iconSet' => 'FontAwesome5', + 'iconName' => 'mountain', + 'transport' => 'bus', + ], + ], + '03.10.2025' => [ + [ + 'time' => '12:00', + 'title' => 'Myhmanhanada çykmak', + 'description' => '', + 'iconSet' => 'FontAwesome', + 'iconName' => 'hotel', + 'transport' => 'bus', + ], + [ + 'time' => '', + 'title' => 'Jidda Aýraporda tarap', + 'description' => '', + 'iconSet' => 'FontAwesome', + 'iconName' => 'bus', + 'transport' => 'bus', + ], + ], + ]; + + Program::create([ + 'name' => 'Adaty Programma', + 'group_id' => Group::first()->id, + 'days' => json_encode($days), + ]); + } +}