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');
|
||||
}
|
||||
}
|
||||
47
app/Filament/Resources/Homepages/HomepageResource.php
Normal file
47
app/Filament/Resources/Homepages/HomepageResource.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Homepages;
|
||||
|
||||
use App\Filament\Resources\Homepages\Pages\CreateHomepage;
|
||||
use App\Filament\Resources\Homepages\Pages\EditHomepage;
|
||||
use App\Filament\Resources\Homepages\Pages\ListHomepages;
|
||||
use App\Filament\Resources\Homepages\Pages\ViewHomepage;
|
||||
use App\Filament\Resources\Homepages\Schemas\HomepageForm;
|
||||
use App\Filament\Resources\Homepages\Schemas\HomepageInfolist;
|
||||
use App\Filament\Resources\Homepages\Tables\HomepagesTable;
|
||||
use App\Models\Homepage;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class HomepageResource extends Resource
|
||||
{
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return auth()->user()?->can('admin') || auth()->user()?->can('manage_pizzas') ?? false;
|
||||
}
|
||||
|
||||
protected static ?string $model = Homepage::class;
|
||||
|
||||
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-home';
|
||||
protected static string | \UnitEnum | null $navigationGroup = 'Treść';
|
||||
protected static ?string $pluralModelLabel = 'Strona główna';
|
||||
protected static ?string $modelLabel = 'Strona główna';
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'Homepage';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return HomepageForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => EditHomepage::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
24
app/Filament/Resources/Homepages/Pages/EditHomepage.php
Normal file
24
app/Filament/Resources/Homepages/Pages/EditHomepage.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Homepages\Pages;
|
||||
|
||||
use App\Filament\Resources\Homepages\HomepageResource;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditHomepage extends EditRecord
|
||||
{
|
||||
protected static string $resource = HomepageResource::class;
|
||||
|
||||
public function mount($record = null): void
|
||||
{
|
||||
$record = $record ?? 1;
|
||||
parent::mount($record);
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
86
app/Filament/Resources/Homepages/Schemas/HomepageForm.php
Normal file
86
app/Filament/Resources/Homepages/Schemas/HomepageForm.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Homepages\Schemas;
|
||||
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\Builder;
|
||||
use Filament\Forms\Components\Builder\Block;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class HomepageForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make()
|
||||
->schema([
|
||||
FileUpload::make('photo')
|
||||
->image()
|
||||
->imageEditor()
|
||||
->disk('public')
|
||||
->directory('homepage')
|
||||
->label('Zdjęcie'),
|
||||
FileUpload::make('photo_mobile')
|
||||
->image()
|
||||
->imageEditor()
|
||||
->disk('public')
|
||||
->directory('homepage')
|
||||
->label('Zdjęcie (widoczne na telefonie)'),
|
||||
FileUpload::make('photo_menu')
|
||||
->image()
|
||||
->imageEditor()
|
||||
->disk('public')
|
||||
->directory('homepage')
|
||||
->label('Zdjęcie (widoczne w menu i galerii)'),
|
||||
TextInput::make('title')
|
||||
->label('Tytuł')
|
||||
->maxLength(2048),
|
||||
RichEditor::make('body')
|
||||
->label('Treść')
|
||||
->columnSpanFull(),
|
||||
RichEditor::make('delivery')
|
||||
->label('Dowóz')
|
||||
->columnSpanFull(),
|
||||
RichEditor::make('address')
|
||||
->label('Adres')
|
||||
->columnSpanFull(),
|
||||
TextInput::make('widget_link')
|
||||
->label('Link do widgetu (mapa google)')
|
||||
->maxLength(2048),
|
||||
]),
|
||||
Section::make()
|
||||
->schema([
|
||||
Builder::make('opening_hours')
|
||||
->label('Godziny otwarcia')
|
||||
->addActionLabel('Dodaj dzień tygodnia')
|
||||
->collapsible()
|
||||
->collapsed()
|
||||
->reorderable()
|
||||
->blocks([
|
||||
Block::make('opening_hour')
|
||||
->label(function (?array $state): string {
|
||||
if ($state === null) {
|
||||
return 'Dzień tygodnia';
|
||||
}
|
||||
|
||||
return $state['name'] ?? 'Dzień tygodnia';
|
||||
})
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
->label('Dzień tygodnia')
|
||||
->required(),
|
||||
TextInput::make('time')
|
||||
->label('Godziny otwarcia')
|
||||
->required(),
|
||||
])
|
||||
->columns(1),
|
||||
])
|
||||
])
|
||||
])->statePath('data');
|
||||
}
|
||||
}
|
||||
65
app/Filament/Resources/Ingredients/IngredientResource.php
Normal file
65
app/Filament/Resources/Ingredients/IngredientResource.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Ingredients;
|
||||
|
||||
use App\Filament\Resources\Ingredients\Pages\CreateIngredient;
|
||||
use App\Filament\Resources\Ingredients\Pages\EditIngredient;
|
||||
use App\Filament\Resources\Ingredients\Pages\ListIngredients;
|
||||
use App\Filament\Resources\Ingredients\Pages\ViewIngredient;
|
||||
use App\Filament\Resources\Ingredients\Schemas\IngredientForm;
|
||||
use App\Filament\Resources\Ingredients\Schemas\IngredientInfolist;
|
||||
use App\Filament\Resources\Ingredients\Tables\IngredientsTable;
|
||||
use App\Models\Ingredient;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class IngredientResource extends Resource
|
||||
{
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return auth()->user()?->can('admin') || auth()->user()?->can('manage_pizzas') ?? false;
|
||||
}
|
||||
|
||||
protected static ?string $model = Ingredient::class;
|
||||
|
||||
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-building-storefront';
|
||||
protected static ?string $pluralModelLabel = 'Składniki';
|
||||
protected static ?string $modelLabel = 'Składnik';
|
||||
protected static ?int $navigationSort = 3;
|
||||
protected static string | \UnitEnum | null $navigationGroup = 'Treść';
|
||||
protected static ?string $recordTitleAttribute = 'Składnik';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return IngredientForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return IngredientInfolist::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return IngredientsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListIngredients::route('/'),
|
||||
'create' => CreateIngredient::route('/create'),
|
||||
'edit' => EditIngredient::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Ingredients\Pages;
|
||||
|
||||
use App\Filament\Resources\Ingredients\IngredientResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateIngredient extends CreateRecord
|
||||
{
|
||||
protected static string $resource = IngredientResource::class;
|
||||
}
|
||||
19
app/Filament/Resources/Ingredients/Pages/EditIngredient.php
Normal file
19
app/Filament/Resources/Ingredients/Pages/EditIngredient.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Ingredients\Pages;
|
||||
|
||||
use App\Filament\Resources\Ingredients\IngredientResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditIngredient extends EditRecord
|
||||
{
|
||||
protected static string $resource = IngredientResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Filament/Resources/Ingredients/Pages/ListIngredients.php
Normal file
19
app/Filament/Resources/Ingredients/Pages/ListIngredients.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Ingredients\Pages;
|
||||
|
||||
use App\Filament\Resources\Ingredients\IngredientResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListIngredients extends ListRecords
|
||||
{
|
||||
protected static string $resource = IngredientResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Ingredients\Schemas;
|
||||
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class IngredientForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->label('Nazwa')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Ingredients\Schemas;
|
||||
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class IngredientInfolist
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Ingredients\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class IngredientsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->label('Nazwa')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('created_at')
|
||||
->label('Data utworzenia')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->label('Data modyfikacji')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->defaultSort('sort_order', 'asc')
|
||||
->reorderable('sort_order')
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
47
app/Filament/Resources/Links/LinkResource.php
Normal file
47
app/Filament/Resources/Links/LinkResource.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Links;
|
||||
|
||||
use App\Filament\Resources\Links\Pages\CreateLink;
|
||||
use App\Filament\Resources\Links\Pages\EditLink;
|
||||
use App\Filament\Resources\Links\Pages\ListLinks;
|
||||
use App\Filament\Resources\Links\Pages\ViewLink;
|
||||
use App\Filament\Resources\Links\Schemas\LinkForm;
|
||||
use App\Filament\Resources\Links\Schemas\LinkInfolist;
|
||||
use App\Filament\Resources\Links\Tables\LinksTable;
|
||||
use App\Models\Link;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class LinkResource extends Resource
|
||||
{
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return auth()->user()?->can('admin') ?? false;
|
||||
}
|
||||
|
||||
protected static ?string $model = Link::class;
|
||||
|
||||
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-link';
|
||||
protected static string | \UnitEnum | null $navigationGroup = 'Treść';
|
||||
protected static ?string $pluralModelLabel = 'Przyciski';
|
||||
protected static ?string $modelLabel = 'Przyciski';
|
||||
protected static ?int $navigationSort = 6;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'Link';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return LinkForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => EditLink::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
26
app/Filament/Resources/Links/Pages/EditLink.php
Normal file
26
app/Filament/Resources/Links/Pages/EditLink.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Links\Pages;
|
||||
|
||||
use App\Filament\Resources\Links\LinkResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditLink extends EditRecord
|
||||
{
|
||||
protected static string $resource = LinkResource::class;
|
||||
|
||||
public function mount($record = null): void
|
||||
{
|
||||
$record = $record ?? 1;
|
||||
parent::mount($record);
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
66
app/Filament/Resources/Links/Schemas/LinkForm.php
Normal file
66
app/Filament/Resources/Links/Schemas/LinkForm.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Links\Schemas;
|
||||
|
||||
use Filament\Forms\Components\Builder;
|
||||
use Filament\Forms\Components\Builder\Block;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class LinkForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make()
|
||||
->schema([
|
||||
Builder::make('links')
|
||||
->label('Przyciski')
|
||||
->addActionLabel('Dodaj przycisk')
|
||||
->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)')
|
||||
->required(),
|
||||
Select::make('btn_style')
|
||||
->label('Styl przycisku')
|
||||
->options([
|
||||
'primary' => 'Pomarańczowy',
|
||||
'secondary' => 'Szary',
|
||||
])
|
||||
->default('primary')
|
||||
->required(),
|
||||
TextInput::make('link')
|
||||
->label('Link')
|
||||
->required(),
|
||||
Toggle::make('external')
|
||||
->label('Zewnętrzny link')
|
||||
->required(),
|
||||
Toggle::make('new_tab')
|
||||
->label('Otwieraj w nowym oknie')
|
||||
->required(),
|
||||
])
|
||||
->columns(2),
|
||||
])
|
||||
])
|
||||
])->statePath('data');
|
||||
}
|
||||
}
|
||||
@@ -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(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
11
app/Filament/Resources/Photos/Pages/CreatePhoto.php
Normal file
11
app/Filament/Resources/Photos/Pages/CreatePhoto.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Photos\Pages;
|
||||
|
||||
use App\Filament\Resources\Photos\PhotoResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreatePhoto extends CreateRecord
|
||||
{
|
||||
protected static string $resource = PhotoResource::class;
|
||||
}
|
||||
21
app/Filament/Resources/Photos/Pages/EditPhoto.php
Normal file
21
app/Filament/Resources/Photos/Pages/EditPhoto.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Photos\Pages;
|
||||
|
||||
use App\Filament\Resources\Photos\PhotoResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditPhoto extends EditRecord
|
||||
{
|
||||
protected static string $resource = PhotoResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ViewAction::make(),
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Filament/Resources/Photos/Pages/ListPhotos.php
Normal file
19
app/Filament/Resources/Photos/Pages/ListPhotos.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Photos\Pages;
|
||||
|
||||
use App\Filament\Resources\Photos\PhotoResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListPhotos extends ListRecords
|
||||
{
|
||||
protected static string $resource = PhotoResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Filament/Resources/Photos/Pages/ViewPhoto.php
Normal file
19
app/Filament/Resources/Photos/Pages/ViewPhoto.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Photos\Pages;
|
||||
|
||||
use App\Filament\Resources\Photos\PhotoResource;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewPhoto extends ViewRecord
|
||||
{
|
||||
protected static string $resource = PhotoResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
61
app/Filament/Resources/Photos/PhotoResource.php
Normal file
61
app/Filament/Resources/Photos/PhotoResource.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Photos;
|
||||
|
||||
use App\Filament\Resources\Photos\Pages\CreatePhoto;
|
||||
use App\Filament\Resources\Photos\Pages\EditPhoto;
|
||||
use App\Filament\Resources\Photos\Pages\ListPhotos;
|
||||
use App\Filament\Resources\Photos\Pages\ViewPhoto;
|
||||
use App\Filament\Resources\Photos\Schemas\PhotoForm;
|
||||
use App\Filament\Resources\Photos\Schemas\PhotoInfolist;
|
||||
use App\Filament\Resources\Photos\Tables\PhotosTable;
|
||||
use App\Models\Photo;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class PhotoResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Photo::class;
|
||||
|
||||
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-photo';
|
||||
protected static string | \UnitEnum | null $navigationGroup = 'Treść';
|
||||
protected static ?string $pluralModelLabel = 'Galeria';
|
||||
protected static ?string $modelLabel = 'Zdjęcie';
|
||||
protected static ?int $navigationSort = 4;
|
||||
protected static ?string $recordTitleAttribute = 'Zdjęcie';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return PhotoForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return PhotoInfolist::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return PhotosTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListPhotos::route('/'),
|
||||
'create' => CreatePhoto::route('/create'),
|
||||
'view' => ViewPhoto::route('/{record}'),
|
||||
'edit' => EditPhoto::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
31
app/Filament/Resources/Photos/Schemas/PhotoForm.php
Normal file
31
app/Filament/Resources/Photos/Schemas/PhotoForm.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Photos\Schemas;
|
||||
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class PhotoForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->label('Nazwa')
|
||||
->required()
|
||||
->maxLength(2048),
|
||||
TextInput::make('description')
|
||||
->label('Opis')
|
||||
->maxLength(2048)
|
||||
->default(null),
|
||||
FileUpload::make('photo')
|
||||
->image()
|
||||
->imageEditor()
|
||||
->disk('public')
|
||||
->directory('photos')
|
||||
->label('Zdjęcie'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
17
app/Filament/Resources/Photos/Schemas/PhotoInfolist.php
Normal file
17
app/Filament/Resources/Photos/Schemas/PhotoInfolist.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Photos\Schemas;
|
||||
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class PhotoInfolist
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
}
|
||||
46
app/Filament/Resources/Photos/Tables/PhotosTable.php
Normal file
46
app/Filament/Resources/Photos/Tables/PhotosTable.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Photos\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ImageColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class PhotosTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->label('Nazwa')
|
||||
->searchable(),
|
||||
TextColumn::make('created_at')
|
||||
->label('Data utworzenia')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: false),
|
||||
TextColumn::make('updated_at')
|
||||
->label('Data modyfikacji')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: false),
|
||||
])
|
||||
->defaultSort('sort_order', 'asc')
|
||||
->reorderable('sort_order')
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
11
app/Filament/Resources/Products/Pages/CreateProduct.php
Normal file
11
app/Filament/Resources/Products/Pages/CreateProduct.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Products\Pages;
|
||||
|
||||
use App\Filament\Resources\Products\ProductResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateProduct extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ProductResource::class;
|
||||
}
|
||||
19
app/Filament/Resources/Products/Pages/EditProduct.php
Normal file
19
app/Filament/Resources/Products/Pages/EditProduct.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Products\Pages;
|
||||
|
||||
use App\Filament\Resources\Products\ProductResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditProduct extends EditRecord
|
||||
{
|
||||
protected static string $resource = ProductResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Filament/Resources/Products/Pages/ListProducts.php
Normal file
19
app/Filament/Resources/Products/Pages/ListProducts.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Products\Pages;
|
||||
|
||||
use App\Filament\Resources\Products\ProductResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListProducts extends ListRecords
|
||||
{
|
||||
protected static string $resource = ProductResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
65
app/Filament/Resources/Products/ProductResource.php
Normal file
65
app/Filament/Resources/Products/ProductResource.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Products;
|
||||
|
||||
use App\Filament\Resources\Products\Pages\CreateProduct;
|
||||
use App\Filament\Resources\Products\Pages\EditProduct;
|
||||
use App\Filament\Resources\Products\Pages\ListProducts;
|
||||
use App\Filament\Resources\Products\Pages\ViewProduct;
|
||||
use App\Filament\Resources\Products\Schemas\ProductForm;
|
||||
use App\Filament\Resources\Products\Schemas\ProductInfolist;
|
||||
use App\Filament\Resources\Products\Tables\ProductsTable;
|
||||
use App\Models\Product;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ProductResource extends Resource
|
||||
{
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return auth()->user()?->can('admin') || auth()->user()?->can('manage_pizzas') ?? false;
|
||||
}
|
||||
|
||||
protected static ?string $model = Product::class;
|
||||
|
||||
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-building-storefront';
|
||||
protected static string | \UnitEnum | null $navigationGroup = 'Treść';
|
||||
protected static ?string $pluralModelLabel = 'Produkty';
|
||||
protected static ?string $modelLabel = 'Produkt';
|
||||
protected static ?int $navigationSort = 2;
|
||||
protected static ?string $recordTitleAttribute = 'Produkt';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return ProductForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return ProductInfolist::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return ProductsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListProducts::route('/'),
|
||||
'create' => CreateProduct::route('/create'),
|
||||
'edit' => EditProduct::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
82
app/Filament/Resources/Products/Schemas/ProductForm.php
Normal file
82
app/Filament/Resources/Products/Schemas/ProductForm.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Products\Schemas;
|
||||
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\Builder;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Forms\Components\Builder\Block;
|
||||
use App\Models\Ingredient;
|
||||
|
||||
class ProductForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make()
|
||||
->schema([
|
||||
TextInput::make('category')
|
||||
->label('Kategoria')
|
||||
->required()
|
||||
->maxLength(2048),
|
||||
TextInput::make('description')
|
||||
->label('Opis')
|
||||
->nullable()
|
||||
->maxLength(2048),
|
||||
]),
|
||||
Section::make()
|
||||
->schema([
|
||||
Builder::make('products')
|
||||
->label('Produkty')
|
||||
->addActionLabel('Dodaj produkt')
|
||||
->collapsible()
|
||||
->collapsed()
|
||||
->reorderable()
|
||||
->blocks([
|
||||
Block::make('product')
|
||||
->label(function (?array $state): string {
|
||||
if ($state === null) {
|
||||
return 'Produkt';
|
||||
}
|
||||
|
||||
return $state['name'] ?? 'Produkt';
|
||||
})
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
->label('Nazwa')
|
||||
->required(),
|
||||
Select::make('ingredients')
|
||||
->label('Składniki')
|
||||
->multiple()
|
||||
->options(Ingredient::pluck('name', 'id'))
|
||||
->searchable(),
|
||||
TextInput::make('description')
|
||||
->label('Opis')
|
||||
->nullable(),
|
||||
TextInput::make('price_small')
|
||||
->label('Cena (mała)')
|
||||
->numeric()
|
||||
->nullable(),
|
||||
TextInput::make('price_medium')
|
||||
->label('Cena (średnia)')
|
||||
->numeric()
|
||||
->nullable(),
|
||||
TextInput::make('price_large')
|
||||
->label('Cena (duża)')
|
||||
->numeric()
|
||||
->nullable(),
|
||||
TextInput::make('spicy')
|
||||
->label('Ostrość')
|
||||
->numeric()
|
||||
->nullable(),
|
||||
])
|
||||
->columns(2),
|
||||
]),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
17
app/Filament/Resources/Products/Schemas/ProductInfolist.php
Normal file
17
app/Filament/Resources/Products/Schemas/ProductInfolist.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Products\Schemas;
|
||||
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class ProductInfolist
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
}
|
||||
44
app/Filament/Resources/Products/Tables/ProductsTable.php
Normal file
44
app/Filament/Resources/Products/Tables/ProductsTable.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Products\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class ProductsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('category')
|
||||
->label('Kategoria')
|
||||
->searchable(),
|
||||
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(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
11
app/Filament/Resources/Promotions/Pages/CreatePromotion.php
Normal file
11
app/Filament/Resources/Promotions/Pages/CreatePromotion.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Promotions\Pages;
|
||||
|
||||
use App\Filament\Resources\Promotions\PromotionResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreatePromotion extends CreateRecord
|
||||
{
|
||||
protected static string $resource = PromotionResource::class;
|
||||
}
|
||||
19
app/Filament/Resources/Promotions/Pages/EditPromotion.php
Normal file
19
app/Filament/Resources/Promotions/Pages/EditPromotion.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Promotions\Pages;
|
||||
|
||||
use App\Filament\Resources\Promotions\PromotionResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditPromotion extends EditRecord
|
||||
{
|
||||
protected static string $resource = PromotionResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Filament/Resources/Promotions/Pages/ListPromotions.php
Normal file
19
app/Filament/Resources/Promotions/Pages/ListPromotions.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Promotions\Pages;
|
||||
|
||||
use App\Filament\Resources\Promotions\PromotionResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListPromotions extends ListRecords
|
||||
{
|
||||
protected static string $resource = PromotionResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
64
app/Filament/Resources/Promotions/PromotionResource.php
Normal file
64
app/Filament/Resources/Promotions/PromotionResource.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Promotions;
|
||||
|
||||
use App\Filament\Resources\Promotions\Pages\CreatePromotion;
|
||||
use App\Filament\Resources\Promotions\Pages\EditPromotion;
|
||||
use App\Filament\Resources\Promotions\Pages\ListPromotions;
|
||||
use App\Filament\Resources\Promotions\Schemas\PromotionForm;
|
||||
use App\Filament\Resources\Promotions\Schemas\PromotionInfolist;
|
||||
use App\Filament\Resources\Promotions\Tables\PromotionsTable;
|
||||
use App\Models\Promotion;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class PromotionResource extends Resource
|
||||
{
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return auth()->user()?->can('admin') || auth()->user()?->can('manage_pizzas') ?? false;
|
||||
}
|
||||
|
||||
protected static ?string $model = Promotion::class;
|
||||
|
||||
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-percent-badge';
|
||||
protected static string | \UnitEnum | null $navigationGroup = 'Treść';
|
||||
protected static ?string $pluralModelLabel = 'Promocje';
|
||||
protected static ?string $modelLabel = 'Promocja';
|
||||
protected static ?int $navigationSort = 3;
|
||||
protected static ?string $recordTitleAttribute = 'Promocja';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return PromotionForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return PromotionInfolist::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return PromotionsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListPromotions::route('/'),
|
||||
'create' => CreatePromotion::route('/create'),
|
||||
'edit' => EditPromotion::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
32
app/Filament/Resources/Promotions/Schemas/PromotionForm.php
Normal file
32
app/Filament/Resources/Promotions/Schemas/PromotionForm.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Promotions\Schemas;
|
||||
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Schemas\Components\Section;
|
||||
|
||||
class PromotionForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make()
|
||||
->schema([
|
||||
TextInput::make('title')
|
||||
->label('Tytuł')
|
||||
->required()
|
||||
->maxLength(2048),
|
||||
TextInput::make('description')
|
||||
->label('Opis')
|
||||
->maxLength(2048)
|
||||
->default(null),
|
||||
TextInput::make('additional_info')
|
||||
->label('Dodatkowe informacje')
|
||||
->maxLength(2048)
|
||||
->default(null),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Promotions\Schemas;
|
||||
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class PromotionInfolist
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
}
|
||||
50
app/Filament/Resources/Promotions/Tables/PromotionsTable.php
Normal file
50
app/Filament/Resources/Promotions/Tables/PromotionsTable.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Promotions\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class PromotionsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('title')
|
||||
->label('Tytuł')
|
||||
->searchable(),
|
||||
TextColumn::make('description')
|
||||
->label('Opis')
|
||||
->searchable(),
|
||||
TextColumn::make('additional_info')
|
||||
->label('Dodatkowe informacje')
|
||||
->searchable(),
|
||||
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(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
11
app/Filament/Resources/Roles/Pages/CreateRole.php
Normal file
11
app/Filament/Resources/Roles/Pages/CreateRole.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Roles\Pages;
|
||||
|
||||
use App\Filament\Resources\Roles\RoleResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateRole extends CreateRecord
|
||||
{
|
||||
protected static string $resource = RoleResource::class;
|
||||
}
|
||||
19
app/Filament/Resources/Roles/Pages/EditRole.php
Normal file
19
app/Filament/Resources/Roles/Pages/EditRole.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Roles\Pages;
|
||||
|
||||
use App\Filament\Resources\Roles\RoleResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditRole extends EditRecord
|
||||
{
|
||||
protected static string $resource = RoleResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Filament/Resources/Roles/Pages/ListRoles.php
Normal file
19
app/Filament/Resources/Roles/Pages/ListRoles.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Roles\Pages;
|
||||
|
||||
use App\Filament\Resources\Roles\RoleResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListRoles extends ListRecords
|
||||
{
|
||||
protected static string $resource = RoleResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
72
app/Filament/Resources/Roles/RoleResource.php
Normal file
72
app/Filament/Resources/Roles/RoleResource.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Roles;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use App\Filament\Resources\Roles\Pages\CreateRole;
|
||||
use App\Filament\Resources\Roles\Pages\EditRole;
|
||||
use App\Filament\Resources\Roles\Pages\ListRoles;
|
||||
use App\Filament\Resources\Roles\Pages\ViewRole;
|
||||
use App\Filament\Resources\Roles\Schemas\RoleForm;
|
||||
use App\Filament\Resources\Roles\Schemas\RoleInfolist;
|
||||
use App\Filament\Resources\Roles\Tables\RolesTable;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class RoleResource extends Resource
|
||||
{
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return auth()->user()?->can('admin') ?? false;
|
||||
}
|
||||
|
||||
protected static ?string $model = Role::class;
|
||||
|
||||
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-user-group';
|
||||
protected static string | \UnitEnum | null $navigationGroup = 'Ustawienia';
|
||||
protected static ?string $pluralModelLabel = 'Role';
|
||||
protected static ?string $modelLabel = 'Role';
|
||||
protected static ?int $navigationSort = 3;
|
||||
protected static ?string $recordTitleAttribute = 'Role';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return RoleForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return RoleInfolist::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return RolesTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListRoles::route('/'),
|
||||
'create' => CreateRole::route('/create'),
|
||||
'edit' => EditRole::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function shouldRegister(): bool
|
||||
{
|
||||
return auth()->user()?->can('edit_users') ?? false;
|
||||
}
|
||||
}
|
||||
26
app/Filament/Resources/Roles/Schemas/RoleForm.php
Normal file
26
app/Filament/Resources/Roles/Schemas/RoleForm.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Roles\Schemas;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class RoleForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->label('Nazwa')
|
||||
->required()
|
||||
->unique(ignoreRecord: true),
|
||||
Select::make('permissions')
|
||||
->label('Uprawnienia')
|
||||
->multiple()
|
||||
->relationship('permissions', 'name')
|
||||
->preload()
|
||||
->searchable(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
16
app/Filament/Resources/Roles/Schemas/RoleInfolist.php
Normal file
16
app/Filament/Resources/Roles/Schemas/RoleInfolist.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Roles\Schemas;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class RoleInfolist
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
}
|
||||
41
app/Filament/Resources/Roles/Tables/RolesTable.php
Normal file
41
app/Filament/Resources/Roles/Tables/RolesTable.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Roles\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
|
||||
class RolesTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->label('Nazwa')
|
||||
->searchable(),
|
||||
TextColumn::make('permissions_count')
|
||||
->counts('permissions')
|
||||
->label('Uprawnienia'),
|
||||
TextColumn::make('created_at')
|
||||
->label('Data utworzenia')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
26
app/Filament/Resources/Sizes/Pages/EditSize.php
Normal file
26
app/Filament/Resources/Sizes/Pages/EditSize.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Sizes\Pages;
|
||||
|
||||
use App\Filament\Resources\Sizes\SizeResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditSize extends EditRecord
|
||||
{
|
||||
protected static string $resource = SizeResource::class;
|
||||
|
||||
public function mount($record = null): void
|
||||
{
|
||||
$record = $record ?? 1;
|
||||
parent::mount($record);
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
57
app/Filament/Resources/Sizes/Schemas/SizeForm.php
Normal file
57
app/Filament/Resources/Sizes/Schemas/SizeForm.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Sizes\Schemas;
|
||||
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class SizeForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make()
|
||||
->schema([
|
||||
TextInput::make('small')
|
||||
->label('Mały rozmiar (opis)')
|
||||
->required()
|
||||
->maxLength(2048),
|
||||
FileUpload::make('small_photo')
|
||||
->image()
|
||||
->imageEditor()
|
||||
->disk('public')
|
||||
->nullable()
|
||||
->directory('sizes')
|
||||
->label('Zdjęcie (małego rozmiaru)'),
|
||||
TextInput::make('medium')
|
||||
->label('Średni rozmiar (opis)')
|
||||
->required()
|
||||
->maxLength(2048),
|
||||
FileUpload::make('medium_photo')
|
||||
->image()
|
||||
->imageEditor()
|
||||
->disk('public')
|
||||
->nullable()
|
||||
->directory('sizes')
|
||||
->label('Zdjęcie (średniego rozmiaru)'),
|
||||
TextInput::make('large')
|
||||
->label('Duży rozmiar (opis)')
|
||||
->required()
|
||||
->maxLength(2048),
|
||||
FileUpload::make('large_photo')
|
||||
->image()
|
||||
->imageEditor()
|
||||
->disk('public')
|
||||
->nullable()
|
||||
->directory('sizes')
|
||||
->label('Zdjęcie (dużego rozmiaru)'),
|
||||
])
|
||||
->columns(1)
|
||||
->columnSpan('full'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
57
app/Filament/Resources/Sizes/SizeResource.php
Normal file
57
app/Filament/Resources/Sizes/SizeResource.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Sizes;
|
||||
|
||||
use App\Filament\Resources\Sizes\Pages\CreateSize;
|
||||
use App\Filament\Resources\Sizes\Pages\EditSize;
|
||||
use App\Filament\Resources\Sizes\Pages\ListSizes;
|
||||
use App\Filament\Resources\Sizes\Pages\ViewSize;
|
||||
use App\Filament\Resources\Sizes\Schemas\SizeForm;
|
||||
use App\Filament\Resources\Sizes\Schemas\SizeInfolist;
|
||||
use App\Filament\Resources\Sizes\Tables\SizesTable;
|
||||
use App\Models\Size;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class SizeResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Size::class;
|
||||
|
||||
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-circle-stack';
|
||||
protected static ?string $pluralModelLabel = 'Rozmiary';
|
||||
protected static ?string $modelLabel = 'Rozmiary';
|
||||
protected static ?int $navigationSort = 3;
|
||||
protected static string | \UnitEnum | null $navigationGroup = 'Treść';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return SizeForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return SizeInfolist::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return SizesTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => EditSize::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
11
app/Filament/Resources/Users/Pages/CreateUser.php
Normal file
11
app/Filament/Resources/Users/Pages/CreateUser.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Users\Pages;
|
||||
|
||||
use App\Filament\Resources\Users\UserResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateUser extends CreateRecord
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
}
|
||||
19
app/Filament/Resources/Users/Pages/EditUser.php
Normal file
19
app/Filament/Resources/Users/Pages/EditUser.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Users\Pages;
|
||||
|
||||
use App\Filament\Resources\Users\UserResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditUser extends EditRecord
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Filament/Resources/Users/Pages/ListUsers.php
Normal file
19
app/Filament/Resources/Users/Pages/ListUsers.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Users\Pages;
|
||||
|
||||
use App\Filament\Resources\Users\UserResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListUsers extends ListRecords
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
44
app/Filament/Resources/Users/Schemas/UserForm.php
Normal file
44
app/Filament/Resources/Users/Schemas/UserForm.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Users\Schemas;
|
||||
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\MultiSelect;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class UserForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->label('Imię i nazwisko')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
TextInput::make('email')
|
||||
->label('Email')
|
||||
->email()
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->unique(ignoreRecord: true),
|
||||
TextInput::make('password')
|
||||
->label('Hasło')
|
||||
->password()
|
||||
->dehydrateStateUsing(fn (?string $state): ?string =>
|
||||
$state ? Hash::make($state) : null
|
||||
)
|
||||
->required(fn (string $operation): bool => $operation === 'create')
|
||||
->maxLength(255)
|
||||
->dehydrated(fn (?string $state): bool =>
|
||||
filled($state)
|
||||
),
|
||||
MultiSelect::make('roles')
|
||||
->label('Role')
|
||||
->relationship('roles', 'name')
|
||||
->preload()
|
||||
->searchable(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
17
app/Filament/Resources/Users/Schemas/UserInfolist.php
Normal file
17
app/Filament/Resources/Users/Schemas/UserInfolist.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Users\Schemas;
|
||||
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class UserInfolist
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
}
|
||||
51
app/Filament/Resources/Users/Tables/UsersTable.php
Normal file
51
app/Filament/Resources/Users/Tables/UsersTable.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Users\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class UsersTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->label('Imię i nazwisko')
|
||||
->searchable(),
|
||||
TextColumn::make('email')
|
||||
->label('Email')
|
||||
->searchable(),
|
||||
TextColumn::make('roles.name')
|
||||
->label('Role')
|
||||
->badge()
|
||||
->searchable(),
|
||||
TextColumn::make('created_at')
|
||||
->label('Data utworzenia')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('updated_at')
|
||||
->label('Data modyfikacji')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
65
app/Filament/Resources/Users/UserResource.php
Normal file
65
app/Filament/Resources/Users/UserResource.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Users;
|
||||
|
||||
use App\Filament\Resources\Users\Pages\CreateUser;
|
||||
use App\Filament\Resources\Users\Pages\EditUser;
|
||||
use App\Filament\Resources\Users\Pages\ListUsers;
|
||||
use App\Filament\Resources\Users\Pages\ViewUser;
|
||||
use App\Filament\Resources\Users\Schemas\UserForm;
|
||||
use App\Filament\Resources\Users\Schemas\UserInfolist;
|
||||
use App\Filament\Resources\Users\Tables\UsersTable;
|
||||
use App\Models\User;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class UserResource extends Resource
|
||||
{
|
||||
protected static ?string $model = User::class;
|
||||
|
||||
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-users';
|
||||
protected static string | \UnitEnum | null $navigationGroup = 'Ustawienia';
|
||||
protected static ?string $modelLabel = 'Użytkownik';
|
||||
protected static ?string $pluralModelLabel = 'Użytkownicy';
|
||||
protected static ?int $navigationSort = 1;
|
||||
protected static ?string $recordTitleAttribute = 'Użytkownik';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return UserForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function infolist(Schema $schema): Schema
|
||||
{
|
||||
return UserInfolist::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return UsersTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListUsers::route('/'),
|
||||
'create' => CreateUser::route('/create'),
|
||||
'edit' => EditUser::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function shouldRegister(): bool
|
||||
{
|
||||
return auth()->user()?->can('view_users') ?? false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user