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;
|
||||
}
|
||||
}
|
||||
21
app/Http/Controllers/Api/FooterController.php
Normal file
21
app/Http/Controllers/Api/FooterController.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use App\Models\Footer;
|
||||
|
||||
class FooterController extends Controller
|
||||
{
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
$footer = Footer::first();
|
||||
$links = $footer ? $footer->links : [];
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'data' => $links
|
||||
]);
|
||||
}
|
||||
}
|
||||
30
app/Http/Controllers/Api/HomepageController.php
Normal file
30
app/Http/Controllers/Api/HomepageController.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Homepage;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class HomepageController extends Controller
|
||||
{
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
$data = Homepage::first();
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'data' => [
|
||||
'photo' => $data->photo ? '/storage/' . $data->photo : null,
|
||||
'photo_mobile' => $data->photo_mobile ? '/storage/' . $data->photo_mobile : null,
|
||||
'photo_menu' => $data->photo_menu ? '/storage/' . $data->photo_menu : null,
|
||||
'title' => $data->title,
|
||||
'body' => $data->body,
|
||||
'address' => $data->address,
|
||||
'delivery' => $data->delivery,
|
||||
'opening_hours' => $data->opening_hours,
|
||||
'widget_link' => $data->widget_link
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
21
app/Http/Controllers/Api/LinkController.php
Normal file
21
app/Http/Controllers/Api/LinkController.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use App\Models\Link;
|
||||
|
||||
class LinkController extends Controller
|
||||
{
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
$link = Link::first();
|
||||
$links = $link ? $link->links : [];
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'data' => $links
|
||||
]);
|
||||
}
|
||||
}
|
||||
20
app/Http/Controllers/Api/NavigationController.php
Normal file
20
app/Http/Controllers/Api/NavigationController.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use App\Models\NavigationLink;
|
||||
|
||||
class NavigationController extends Controller
|
||||
{
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
$navigation = NavigationLink::orderBy('sort_order', 'asc')->get();
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'data' => $navigation
|
||||
]);
|
||||
}
|
||||
}
|
||||
26
app/Http/Controllers/Api/PhotoController.php
Normal file
26
app/Http/Controllers/Api/PhotoController.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use App\Models\Photo;
|
||||
|
||||
class PhotoController extends Controller
|
||||
{
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
$photos = Photo::orderBy('sort_order', 'asc')->get();
|
||||
|
||||
$photosWithPaths = $photos->map(function ($photo) {
|
||||
$data = $photo->toArray();
|
||||
$data['photo'] = $photo->photo ? '/storage/' . $photo->photo : null;
|
||||
return $data;
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'data' => $photosWithPaths
|
||||
]);
|
||||
}
|
||||
}
|
||||
41
app/Http/Controllers/Api/ProductController.php
Normal file
41
app/Http/Controllers/Api/ProductController.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use App\Models\Product;
|
||||
use App\Models\Ingredient;
|
||||
|
||||
class ProductController extends Controller
|
||||
{
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
$products = Product::all();
|
||||
$ingredients = Ingredient::all()->keyBy('id');
|
||||
|
||||
$productsWithIngredients = $products->map(function ($product) use ($ingredients) {
|
||||
$productData = $product->toArray();
|
||||
|
||||
if (isset($productData['products']) && is_array($productData['products'])) {
|
||||
$productData['products'] = collect($productData['products'])->map(function ($item) use ($ingredients) {
|
||||
if (isset($item['data']['ingredients'])) {
|
||||
$item['data']['ingredients'] = collect($item['data']['ingredients'])
|
||||
->map(fn($id) => $ingredients->get($id))
|
||||
->filter()
|
||||
->values()
|
||||
->toArray();
|
||||
}
|
||||
return $item;
|
||||
})->toArray();
|
||||
}
|
||||
|
||||
return $productData;
|
||||
});
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'data' => $productsWithIngredients
|
||||
]);
|
||||
}
|
||||
}
|
||||
20
app/Http/Controllers/Api/PromotionController.php
Normal file
20
app/Http/Controllers/Api/PromotionController.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use App\Models\Promotion;
|
||||
|
||||
class PromotionController extends Controller
|
||||
{
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
$promotions = Promotion::orderBy('sort_order', 'asc')->get();
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'data' => $promotions
|
||||
]);
|
||||
}
|
||||
}
|
||||
40
app/Http/Controllers/Api/SizeController.php
Normal file
40
app/Http/Controllers/Api/SizeController.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use App\Models\Size;
|
||||
|
||||
class SizeController extends Controller
|
||||
{
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
$size = Size::first();
|
||||
|
||||
if (!$size) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => 'Size configuration not found'
|
||||
], 404);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'data' => [
|
||||
'small' => [
|
||||
'description' => $size->small,
|
||||
'photo' => $size->small_photo ? '/storage/' . $size->small_photo : null,
|
||||
],
|
||||
'medium' => [
|
||||
'description' => $size->medium,
|
||||
'photo' => $size->medium_photo ? '/storage/' . $size->medium_photo : null,
|
||||
],
|
||||
'large' => [
|
||||
'description' => $size->large,
|
||||
'photo' => $size->large_photo ? '/storage/' . $size->large_photo : null,
|
||||
],
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
8
app/Http/Controllers/Controller.php
Normal file
8
app/Http/Controllers/Controller.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
abstract class Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
52
app/Http/Middleware/HandleInertiaRequests.php
Normal file
52
app/Http/Middleware/HandleInertiaRequests.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Inspiring;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Middleware;
|
||||
use Tighten\Ziggy\Ziggy;
|
||||
|
||||
class HandleInertiaRequests extends Middleware
|
||||
{
|
||||
/**
|
||||
* The root template that's loaded on the first page visit.
|
||||
*
|
||||
* @see https://inertiajs.com/server-side-setup#root-template
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $rootView = 'app';
|
||||
|
||||
/**
|
||||
* Determines the current asset version.
|
||||
*
|
||||
* @see https://inertiajs.com/asset-versioning
|
||||
*/
|
||||
public function version(Request $request): ?string
|
||||
{
|
||||
return parent::version($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the props that are shared by default.
|
||||
*
|
||||
* @see https://inertiajs.com/shared-data
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function share(Request $request): array
|
||||
{
|
||||
[$message, $author] = str(Inspiring::quotes()->random())->explode('-');
|
||||
|
||||
return [
|
||||
...parent::share($request),
|
||||
'name' => config('app.name'),
|
||||
'ziggy' => fn (): array => [
|
||||
...(new Ziggy)->toArray(),
|
||||
'location' => $request->url(),
|
||||
],
|
||||
'sidebarOpen' => ! $request->hasCookie('sidebar_state') || $request->cookie('sidebar_state') === 'true',
|
||||
];
|
||||
}
|
||||
}
|
||||
21
app/Models/Footer.php
Normal file
21
app/Models/Footer.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Footer extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'footer';
|
||||
|
||||
protected $fillable = [
|
||||
'links'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'links' => 'array',
|
||||
];
|
||||
}
|
||||
29
app/Models/Homepage.php
Normal file
29
app/Models/Homepage.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Homepage extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'homepage';
|
||||
|
||||
protected $fillable = [
|
||||
'photo',
|
||||
'photo_mobile',
|
||||
'photo_menu',
|
||||
'title',
|
||||
'body',
|
||||
'address',
|
||||
'delivery',
|
||||
'opening_hours',
|
||||
'widget_link'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'opening_hours' => 'array',
|
||||
];
|
||||
}
|
||||
22
app/Models/Ingredient.php
Normal file
22
app/Models/Ingredient.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use App\Models\Product;
|
||||
|
||||
class Ingredient extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'sort_order',
|
||||
];
|
||||
|
||||
public function products()
|
||||
{
|
||||
return $this->belongsToMany(Product::class);
|
||||
}
|
||||
}
|
||||
21
app/Models/Link.php
Normal file
21
app/Models/Link.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Link extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'link';
|
||||
|
||||
protected $fillable = [
|
||||
'links'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'links' => 'array',
|
||||
];
|
||||
}
|
||||
20
app/Models/NavigationLink.php
Normal file
20
app/Models/NavigationLink.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class NavigationLink extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'navigation_links';
|
||||
|
||||
protected $fillable = [
|
||||
'sort_order',
|
||||
'name',
|
||||
'link',
|
||||
'external'
|
||||
];
|
||||
}
|
||||
20
app/Models/Photo.php
Normal file
20
app/Models/Photo.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Photo extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'photos';
|
||||
|
||||
protected $fillable = [
|
||||
'sort_order',
|
||||
'name',
|
||||
'description',
|
||||
'photo'
|
||||
];
|
||||
}
|
||||
34
app/Models/Product.php
Normal file
34
app/Models/Product.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Product extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'products';
|
||||
|
||||
protected $fillable = [
|
||||
'sort_order',
|
||||
'category',
|
||||
'products',
|
||||
'description'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'products' => 'array',
|
||||
];
|
||||
|
||||
public function ingredients()
|
||||
{
|
||||
return Ingredient::whereIn('id', collect($this->products ?? [])
|
||||
->pluck('ingredients')
|
||||
->flatten()
|
||||
->unique()
|
||||
->toArray()
|
||||
);
|
||||
}
|
||||
}
|
||||
20
app/Models/Promotion.php
Normal file
20
app/Models/Promotion.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Promotion extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'promotions';
|
||||
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'description',
|
||||
'additional_info',
|
||||
'sort_order',
|
||||
];
|
||||
}
|
||||
22
app/Models/Size.php
Normal file
22
app/Models/Size.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Size extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'size';
|
||||
|
||||
protected $fillable = [
|
||||
'small',
|
||||
'small_photo',
|
||||
'medium',
|
||||
'medium_photo',
|
||||
'large',
|
||||
'large_photo'
|
||||
];
|
||||
}
|
||||
57
app/Models/User.php
Normal file
57
app/Models/User.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Database\Factories\UserFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Filament\Models\Contracts\FilamentUser;
|
||||
use Filament\Panel;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
class User extends Authenticatable implements FilamentUser
|
||||
{
|
||||
/** @use HasFactory<UserFactory> */
|
||||
use HasFactory, Notifiable, HasRoles;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
|
||||
public function canAccessPanel(Panel $panel): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
27
app/Providers/AppServiceProvider.php
Normal file
27
app/Providers/AppServiceProvider.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
if ($this->app->environment('production')) {
|
||||
URL::forceScheme('https');
|
||||
}
|
||||
}
|
||||
}
|
||||
26
app/Providers/AuthServiceProvider.php
Normal file
26
app/Providers/AuthServiceProvider.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The model to policy mappings for the application.
|
||||
*
|
||||
* @var array<class-string, class-string>
|
||||
*/
|
||||
protected $policies = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
$this->registerPolicies();
|
||||
}
|
||||
}
|
||||
15
app/Providers/EventServiceProvider.php
Normal file
15
app/Providers/EventServiceProvider.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected $listen = [];
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
81
app/Providers/Filament/AdminPanelProvider.php
Normal file
81
app/Providers/Filament/AdminPanelProvider.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers\Filament;
|
||||
|
||||
use Filament\Widgets\AccountWidget;
|
||||
use Filament\Widgets\FilamentInfoWidget;
|
||||
use Filament\Http\Middleware\Authenticate;
|
||||
use Filament\Http\Middleware\AuthenticateSession;
|
||||
use Filament\Http\Middleware\DisableBladeIconComponents;
|
||||
use Filament\Http\Middleware\DispatchServingFilamentEvent;
|
||||
use Filament\Pages;
|
||||
use Filament\Panel;
|
||||
use Filament\PanelProvider;
|
||||
use Filament\Support\Colors\Color;
|
||||
use Filament\Widgets;
|
||||
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies;
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
|
||||
use Illuminate\Routing\Middleware\SubstituteBindings;
|
||||
use Illuminate\Session\Middleware\StartSession;
|
||||
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
||||
use Filament\View\PanelsRenderHook;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Composer\InstalledVersions;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Filament\FontProviders\GoogleFontProvider;
|
||||
|
||||
class AdminPanelProvider extends PanelProvider
|
||||
{
|
||||
public function panel(Panel $panel): Panel
|
||||
{
|
||||
return $panel
|
||||
->default()
|
||||
->authGuard('web')
|
||||
->id('admin')
|
||||
->path('admin')
|
||||
->login()
|
||||
->colors([
|
||||
'primary' => Color::Amber,
|
||||
])
|
||||
->brandLogo(fn () => view('filament.admin.logo'))
|
||||
->brandLogoHeight('2rem')
|
||||
->font('Oswald', provider: GoogleFontProvider::class)
|
||||
->favicon(asset('/storage/favicon/favicon-32x32.png'))
|
||||
->breadcrumbs(false)
|
||||
->collapsibleNavigationGroups(false)
|
||||
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
|
||||
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
|
||||
->pages([
|
||||
// Pages\Dashboard::class,
|
||||
])
|
||||
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
|
||||
->widgets([
|
||||
AccountWidget::class,
|
||||
FilamentInfoWidget::class,
|
||||
])
|
||||
->renderHook(
|
||||
PanelsRenderHook::GLOBAL_SEARCH_BEFORE,
|
||||
fn() => Blade::render(Auth::check() ? '<footer style="width:100%; display:flex; flex-direction:column; align-items:center; justify-content:center;"><div style="font-size:0.875rem; color:#6B7280; text-align:center; color:#9CA3AF;">Wykonane przez <a href="https://bwitek.dev" target="_blank" style="font-weight:500;">Bogusław Witek</a>.</div><div style="font-size:0.875rem; color:#6B7280; text-align:center; color:#9CA3AF;">© <?php echo date("Y"); ?> <a href="https://ghost-pizza.pl" target="_blank" style="font-weight:500;">GHOST PIZZA Krzysztof Szymański</a>. Wszelkie prawa zastrzeżone.</div></footer>' : null)
|
||||
)
|
||||
->renderHook(
|
||||
PanelsRenderHook::BODY_END,
|
||||
fn() => Blade::render(!Auth::check() ? '<footer style="position:fixed; bottom:0; left:0; right:0; text-align:center; width:100%; background-color:transparent; box-shadow:0 1px 3px rgba(0,0,0,0.1); display:flex; flex-direction:column; align-items:center; justify-content:center;"><div style="margin-top:0.5rem; font-size:0.875rem; color:#6B7280; text-align:center; color:#9CA3AF;">© <?php echo date("Y"); ?> <a href="https://ghost-pizza.pl" target="_blank" style="font-weight:500;">GHOST PIZZA Krzysztof Szymański</a>. Wszelkie prawa zastrzeżone.</div><div style="margin-bottom:0.5rem; font-size:0.875rem; color:#6B7280; text-align:center; color:#9CA3AF;">Wykonane przez <a href="https://bwitek.dev" target="_blank" style="font-weight:500;">Bogusław Witek</a>.</div></footer>' : null)
|
||||
)
|
||||
->globalSearch(false)
|
||||
->middleware([
|
||||
EncryptCookies::class,
|
||||
AddQueuedCookiesToResponse::class,
|
||||
StartSession::class,
|
||||
AuthenticateSession::class,
|
||||
ShareErrorsFromSession::class,
|
||||
VerifyCsrfToken::class,
|
||||
SubstituteBindings::class,
|
||||
DisableBladeIconComponents::class,
|
||||
DispatchServingFilamentEvent::class,
|
||||
])
|
||||
->authMiddleware([
|
||||
Authenticate::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
35
app/Providers/RouteServiceProvider.php
Normal file
35
app/Providers/RouteServiceProvider.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
public const HOME = '/';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, etc.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
||||
});
|
||||
|
||||
$this->routes(function () {
|
||||
// API Routes
|
||||
Route::middleware('api')
|
||||
->prefix('api')
|
||||
->group(base_path('routes/api.php'));
|
||||
|
||||
// Web Routes
|
||||
Route::middleware('web')
|
||||
->group(base_path('routes/web.php'));
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user