Skip to content

Commit

Permalink
add segnalazioni relation manager
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-introini committed Jun 4, 2024
1 parent 4a193f8 commit e1efa0a
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 15 deletions.
11 changes: 10 additions & 1 deletion app/Filament/Resources/SantoResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,16 @@ public static function table(Table $table): Table
public static function getPages(): array
{
return [
'index' => Pages\ManageSanti::route('/'),
'index' => Pages\ListSanti::route('/'),
'create' => Pages\CreateSanto::route('/create'),
'edit' => Pages\EditSanto::route('/{record}/edit'),
];
}

public static function getRelations(): array
{
return [
RelationManagers\SegnalazioniRelationManager::class,
];
}
}
11 changes: 11 additions & 0 deletions app/Filament/Resources/SantoResource/Pages/CreateSanto.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace App\Filament\Resources\SantoResource\Pages;

use App\Filament\Resources\SantoResource;
use Filament\Resources\Pages\CreateRecord;

class CreateSanto extends CreateRecord
{
protected static string $resource = SantoResource::class;
}
19 changes: 19 additions & 0 deletions app/Filament/Resources/SantoResource/Pages/EditSanto.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Filament\Resources\SantoResource\Pages;

use App\Filament\Resources\SantoResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;

class EditSanto extends EditRecord
{
protected static string $resource = SantoResource::class;

protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use App\Filament\Resources\SantoResource;
use Filament\Actions;
use Filament\Resources\Pages\ManageRecords;
use Filament\Resources\Pages\ListRecords;

class ManageSanti extends ManageRecords
class ListSanti extends ListRecords
{
protected static string $resource = SantoResource::class;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace App\Filament\Resources\SantoResource\RelationManagers;

use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;

class SegnalazioniRelationManager extends RelationManager
{
protected static string $relationship = 'segnalazioni';

public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('testo_segnalazione')
->required()
->maxLength(255),
]);
}

public function table(Table $table): Table
{
return $table
->recordTitleAttribute('testo_segnalazione')
->columns([
Tables\Columns\TextColumn::make('testo_segnalazione'),
])
->filters([
//
])
->headerActions([
Tables\Actions\CreateAction::make(),
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}
}
9 changes: 3 additions & 6 deletions app/Filament/Resources/UserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@
use App\Filament\Resources\UserResource\Pages;
use App\Filament\Resources\UserResource\RelationManagers;
use App\Models\User;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;

class UserResource extends Resource
{
Expand Down Expand Up @@ -62,9 +59,9 @@ public static function getRelations(): array
public static function getPages(): array
{
return [
'index' => Pages\ListUsers::route('/'),
'create' => Pages\CreateUser::route('/create'),
'edit' => Pages\EditUser::route('/{record}/edit'),
'index' => SantoResource\Pages\ListSanti::route('/'),
'create' => SantoResource\Pages\CreateSanto::route('/create'),
'edit' => SantoResource\Pages\EditSanto::route('/{record}/edit'),
];
}

Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e1efa0a

Please sign in to comment.