Initial commit
This commit is contained in:
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(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user