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