diff --git a/app/Filament/Resources/Hunts/HuntsResource.php b/app/Filament/Resources/Hunts/HuntsResource.php new file mode 100644 index 0000000..abc4849 --- /dev/null +++ b/app/Filament/Resources/Hunts/HuntsResource.php @@ -0,0 +1,106 @@ +components([ + TextInput::make('title') + ->required() + ->maxLength(255), + Textarea::make('description') + ->columnSpanFull(), + Select::make('status') + ->options(HuntStatus::class) + ->required(), + Select::make('difficulty') + ->options(HuntDifficulty::class) + ->required(), + TextInput::make('city') + ->required() + ->maxLength(255), + DateTimePicker::make('start_at'), + DateTimePicker::make('end_at'), + TextInput::make('latitude') + ->numeric(), + TextInput::make('longitude') + ->numeric(), + ]); + } + + public static function table(Table $table): Table + { + return $table + ->columns([ + Tables\Columns\TextColumn::make('title') + ->searchable(), + Tables\Columns\TextColumn::make('status') + ->searchable(), + Tables\Columns\TextColumn::make('difficulty'), + Tables\Columns\TextColumn::make('city') + ->searchable(), + Tables\Columns\TextColumn::make('start_at') + ->dateTime() + ->sortable(), + Tables\Columns\TextColumn::make('created_at') + ->dateTime() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + ]) + ->filters([ + // + ]) + ->actions([ + EditAction::make(), + ]) + ->bulkActions([ + BulkActionGroup::make([ + DeleteBulkAction::make(), + ]), + ]); + } + + public static function getRelations(): array + { + return [ + // + ]; + } + + public static function getPages(): array + { + return [ + 'index' => ListHunts::route('/'), + 'create' => CreateHunts::route('/create'), + 'edit' => EditHunts::route('/{record}/edit'), + ]; + } +} diff --git a/app/Filament/Resources/Hunts/Pages/CreateHunts.php b/app/Filament/Resources/Hunts/Pages/CreateHunts.php new file mode 100644 index 0000000..b35b2e0 --- /dev/null +++ b/app/Filament/Resources/Hunts/Pages/CreateHunts.php @@ -0,0 +1,11 @@ +role === UserRole::ADMIN || $user->role === UserRole::ORGA; + } + + /** + * Determine whether the user can view the model. + */ + public function view(User $user, Hunts $hunts): bool + { + return $user->role === UserRole::ADMIN || $user->role === UserRole::ORGA; + } + + /** + * Determine whether the user can create models. + */ + public function create(User $user): bool + { + return $user->role === UserRole::ADMIN || $user->role === UserRole::ORGA; + } + + /** + * Determine whether the user can update the model. + */ + public function update(User $user, Hunts $hunts): bool + { + return $user->role === UserRole::ADMIN || $user->role === UserRole::ORGA; + } + + /** + * Determine whether the user can delete the model. + */ + public function delete(User $user, Hunts $hunts): bool + { + return $user->role === UserRole::ADMIN; + } + + /** + * Determine whether the user can restore the model. + */ + public function restore(User $user, Hunts $hunts): bool + { + return $user->role === UserRole::ADMIN; + } + + /** + * Determine whether the user can permanently delete the model. + */ + public function forceDelete(User $user, Hunts $hunts): bool + { + return $user->role === UserRole::ADMIN; + } +}