feat: implement Change resource with CRUD functionality and migration
update image tags to v0.0.8 in build scripts and docker-compose files
This commit is contained in:
parent
64a7d1d2f4
commit
5b0e55c4b2
20 changed files with 408 additions and 88 deletions
53
app/Filament/Resources/Changes/ChangeResource.php
Normal file
53
app/Filament/Resources/Changes/ChangeResource.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Changes;
|
||||
|
||||
use App\Filament\Resources\Changes\Pages\CreateChange;
|
||||
use App\Filament\Resources\Changes\Pages\EditChange;
|
||||
use App\Filament\Resources\Changes\Pages\ListChanges;
|
||||
use App\Filament\Resources\Changes\Schemas\ChangeForm;
|
||||
use App\Filament\Resources\Changes\Tables\ChangesTable;
|
||||
use App\Models\Change as ModelsChange;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ChangeResource extends Resource
|
||||
{
|
||||
protected static ?string $model = ModelsChange::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::ArrowUpOnSquareStack;
|
||||
|
||||
public static function getNavigationGroup(): ?string
|
||||
{
|
||||
return 'Settings';
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return ChangeForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return ChangesTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListChanges::route('/'),
|
||||
'create' => CreateChange::route('/create'),
|
||||
'edit' => EditChange::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
18
app/Filament/Resources/Changes/Pages/CreateChange.php
Normal file
18
app/Filament/Resources/Changes/Pages/CreateChange.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Changes\Pages;
|
||||
|
||||
use App\Filament\Resources\Changes\ChangeResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateChange extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ChangeResource::class;
|
||||
|
||||
protected function mutateFormDataBeforeCreate(array $data): array
|
||||
{
|
||||
$data['user_id'] = auth()->id();
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
16
app/Filament/Resources/Changes/Pages/EditChange.php
Normal file
16
app/Filament/Resources/Changes/Pages/EditChange.php
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Changes\Pages;
|
||||
|
||||
use App\Filament\Resources\Changes\ChangeResource;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditChange extends EditRecord
|
||||
{
|
||||
protected static string $resource = ChangeResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
19
app/Filament/Resources/Changes/Pages/ListChanges.php
Normal file
19
app/Filament/Resources/Changes/Pages/ListChanges.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Changes\Pages;
|
||||
|
||||
use App\Filament\Resources\Changes\ChangeResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListChanges extends ListRecords
|
||||
{
|
||||
protected static string $resource = ChangeResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
28
app/Filament/Resources/Changes/Schemas/ChangeForm.php
Normal file
28
app/Filament/Resources/Changes/Schemas/ChangeForm.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Changes\Schemas;
|
||||
|
||||
use Filament\Forms\Components\Select as FormSelect;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class ChangeForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Textarea::make('note')
|
||||
->label('Note')
|
||||
->required(),
|
||||
FormSelect::make('type')
|
||||
->label('Type')
|
||||
->options([
|
||||
'go-live' => 'Go Live',
|
||||
'general' => 'General',
|
||||
])
|
||||
->default('go-live')
|
||||
->required(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
34
app/Filament/Resources/Changes/Tables/ChangesTable.php
Normal file
34
app/Filament/Resources/Changes/Tables/ChangesTable.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Changes\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ChangesTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('note')
|
||||
->label('Note')
|
||||
->wrap(),
|
||||
TextColumn::make('type')
|
||||
->label('Type'),
|
||||
TextColumn::make('user.name')
|
||||
->label('User'),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue