Initial commit
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\NavigationLinks;
|
||||
|
||||
use App\Filament\Resources\NavigationLinks\Pages\CreateNavigationLink;
|
||||
use App\Filament\Resources\NavigationLinks\Pages\EditNavigationLink;
|
||||
use App\Filament\Resources\NavigationLinks\Pages\ListNavigationLinks;
|
||||
use App\Filament\Resources\NavigationLinks\Pages\ViewNavigationLink;
|
||||
use App\Filament\Resources\NavigationLinks\Schemas\NavigationLinkForm;
|
||||
use App\Filament\Resources\NavigationLinks\Schemas\NavigationLinkInfolist;
|
||||
use App\Filament\Resources\NavigationLinks\Tables\NavigationLinksTable;
|
||||
use App\Models\NavigationLink;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class NavigationLinkResource extends Resource
|
||||
{
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return auth()->user()?->can('admin') ?? false;
|
||||
}
|
||||
|
||||
protected static ?string $model = NavigationLink::class;
|
||||
|
||||
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-bars-4';
|
||||
protected static string | \UnitEnum | null $navigationGroup = 'Treść';
|
||||
protected static ?string $pluralModelLabel = 'Nawigacja';
|
||||
protected static ?string $modelLabel = 'Nawigacja';
|
||||
protected static ?int $navigationSort = 5;
|
||||
protected static ?string $recordTitleAttribute = 'Nawigacja';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return NavigationLinkForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return NavigationLinkInfolist::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return NavigationLinksTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListNavigationLinks::route('/'),
|
||||
'create' => CreateNavigationLink::route('/create'),
|
||||
'edit' => EditNavigationLink::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\NavigationLinks\Pages;
|
||||
|
||||
use App\Filament\Resources\NavigationLinks\NavigationLinkResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateNavigationLink extends CreateRecord
|
||||
{
|
||||
protected static string $resource = NavigationLinkResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\NavigationLinks\Pages;
|
||||
|
||||
use App\Filament\Resources\NavigationLinks\NavigationLinkResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditNavigationLink extends EditRecord
|
||||
{
|
||||
protected static string $resource = NavigationLinkResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\NavigationLinks\Pages;
|
||||
|
||||
use App\Filament\Resources\NavigationLinks\NavigationLinkResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListNavigationLinks extends ListRecords
|
||||
{
|
||||
protected static string $resource = NavigationLinkResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\NavigationLinks\Schemas;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
|
||||
class NavigationLinkForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make()
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
->label('Nazwa')
|
||||
->required()
|
||||
->maxLength(2048),
|
||||
TextInput::make('link')
|
||||
->label('Link')
|
||||
->required()
|
||||
->maxLength(2048),
|
||||
Toggle::make('external')
|
||||
->label('Zewnętrzny link')
|
||||
->required(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\NavigationLinks\Schemas;
|
||||
|
||||
use Filament\Infolists\Components\IconEntry;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class NavigationLinkInfolist
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\NavigationLinks\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class NavigationLinksTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->label('Nazwa')
|
||||
->searchable(),
|
||||
TextColumn::make('link')
|
||||
->label('Link')
|
||||
->searchable(),
|
||||
IconColumn::make('external')
|
||||
->label('Zewnętrzny link')
|
||||
->boolean(),
|
||||
TextColumn::make('created_at')
|
||||
->label('Data utworzenia')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->label('Data modyfikacji')
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->defaultSort('sort_order', 'asc')
|
||||
->reorderable('sort_order')
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user