Initial commit
This commit is contained in:
45
app/Filament/Resources/Footers/FooterResource.php
Normal file
45
app/Filament/Resources/Footers/FooterResource.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Footers;
|
||||
|
||||
use App\Filament\Resources\Footers\Pages\CreateFooter;
|
||||
use App\Filament\Resources\Footers\Pages\EditFooter;
|
||||
use App\Filament\Resources\Footers\Pages\ListFooters;
|
||||
use App\Filament\Resources\Footers\Pages\ViewFooter;
|
||||
use App\Filament\Resources\Footers\Schemas\FooterForm;
|
||||
use App\Filament\Resources\Footers\Schemas\FooterInfolist;
|
||||
use App\Filament\Resources\Footers\Tables\FootersTable;
|
||||
use App\Models\Footer;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class FooterResource extends Resource
|
||||
{
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return auth()->user()?->can('admin') ?? false;
|
||||
}
|
||||
|
||||
protected static ?string $model = Footer::class;
|
||||
|
||||
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-adjustments-horizontal';
|
||||
protected static string | \UnitEnum | null $navigationGroup = 'Treść';
|
||||
protected static ?string $pluralModelLabel = 'Stopka';
|
||||
protected static ?string $modelLabel = 'Stopka';
|
||||
protected static ?int $navigationSort = 7;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return FooterForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => EditFooter::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
26
app/Filament/Resources/Footers/Pages/EditFooter.php
Normal file
26
app/Filament/Resources/Footers/Pages/EditFooter.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Footers\Pages;
|
||||
|
||||
use App\Filament\Resources\Footers\FooterResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditFooter extends EditRecord
|
||||
{
|
||||
protected static string $resource = FooterResource::class;
|
||||
|
||||
public function mount($record = null): void
|
||||
{
|
||||
$record = $record ?? 1;
|
||||
parent::mount($record);
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
53
app/Filament/Resources/Footers/Schemas/FooterForm.php
Normal file
53
app/Filament/Resources/Footers/Schemas/FooterForm.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Footers\Schemas;
|
||||
|
||||
use Filament\Forms\Components\Builder;
|
||||
use Filament\Forms\Components\Builder\Block;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class FooterForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make()
|
||||
->schema([
|
||||
Builder::make('links')
|
||||
->label('Odnośniki')
|
||||
->addActionLabel('Dodaj odnośnik')
|
||||
->collapsible()
|
||||
->collapsed()
|
||||
->reorderable()
|
||||
->blocks([
|
||||
Block::make('link')
|
||||
->label(function (?array $state): string {
|
||||
if ($state === null) {
|
||||
return 'Odnośnik';
|
||||
}
|
||||
|
||||
return $state['name'] ?? 'Odnośnik';
|
||||
})
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
->label('Nazwa')
|
||||
->required(),
|
||||
TextInput::make('icon')
|
||||
->label('Ikona (FontAwesome)'),
|
||||
TextInput::make('link')
|
||||
->label('Link')
|
||||
->required(),
|
||||
Toggle::make('external')
|
||||
->label('Zewnętrzny link')
|
||||
->required(),
|
||||
])
|
||||
->columns(2),
|
||||
])
|
||||
])
|
||||
])->statePath('data');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user