feat(LRL App): init V0
This commit is contained in:
11
app/Filament/Resources/Services/Pages/CreateService.php
Normal file
11
app/Filament/Resources/Services/Pages/CreateService.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Services\Pages;
|
||||
|
||||
use App\Filament\Resources\Services\ServiceResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateService extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ServiceResource::class;
|
||||
}
|
||||
19
app/Filament/Resources/Services/Pages/EditService.php
Normal file
19
app/Filament/Resources/Services/Pages/EditService.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Services\Pages;
|
||||
|
||||
use App\Filament\Resources\Services\ServiceResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditService extends EditRecord
|
||||
{
|
||||
protected static string $resource = ServiceResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Filament/Resources/Services/Pages/ListServices.php
Normal file
19
app/Filament/Resources/Services/Pages/ListServices.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Services\Pages;
|
||||
|
||||
use App\Filament\Resources\Services\ServiceResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListServices extends ListRecords
|
||||
{
|
||||
protected static string $resource = ServiceResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
37
app/Filament/Resources/Services/Schemas/ServiceForm.php
Normal file
37
app/Filament/Resources/Services/Schemas/ServiceForm.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Services\Schemas;
|
||||
|
||||
use App\Models\Service;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class ServiceForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make(fn (?Service $record) => $record?->name ?? Service::getAttributeLabel('name'))
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
->label(Service::getAttributeLabel('name'))
|
||||
->required(),
|
||||
TextInput::make('identifier')
|
||||
->label(Service::getAttributeLabel('identifier'))
|
||||
->required(),
|
||||
TextInput::make('description')
|
||||
->label(Service::getAttributeLabel('description'))
|
||||
->default(null),
|
||||
TextInput::make('url')
|
||||
->label(Service::getAttributeLabel('url'))
|
||||
->url()
|
||||
->required(),
|
||||
TextInput::make('icon')
|
||||
->label(Service::getAttributeLabel('icon'))
|
||||
->default(null),
|
||||
])
|
||||
]);
|
||||
}
|
||||
}
|
||||
48
app/Filament/Resources/Services/ServiceResource.php
Normal file
48
app/Filament/Resources/Services/ServiceResource.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Services;
|
||||
|
||||
use App\Filament\Resources\Services\Pages\CreateService;
|
||||
use App\Filament\Resources\Services\Pages\EditService;
|
||||
use App\Filament\Resources\Services\Pages\ListServices;
|
||||
use App\Filament\Resources\Services\Schemas\ServiceForm;
|
||||
use App\Filament\Resources\Services\Tables\ServicesTable;
|
||||
use App\Models\Service;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ServiceResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Service::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedPuzzlePiece;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return ServiceForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return ServicesTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListServices::route('/'),
|
||||
'create' => CreateService::route('/create'),
|
||||
'edit' => EditService::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
51
app/Filament/Resources/Services/Tables/ServicesTable.php
Normal file
51
app/Filament/Resources/Services/Tables/ServicesTable.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Services\Tables;
|
||||
|
||||
use App\Models\Service;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ServicesTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->label(Service::getAttributeLabel('name'))
|
||||
->searchable(),
|
||||
TextColumn::make('identifier')
|
||||
->label(Service::getAttributeLabel('identifier'))
|
||||
->searchable(),
|
||||
TextColumn::make('icon')
|
||||
->searchable(),
|
||||
TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user