Add all files
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Resources\CategoryResource\Pages;
|
||||
|
||||
use App\Admin\Resources\CategoryResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateCategory extends CreateRecord
|
||||
{
|
||||
protected static string $resource = CategoryResource::class;
|
||||
}
|
||||
31
app/Admin/Resources/CategoryResource/Pages/EditCategory.php
Normal file
31
app/Admin/Resources/CategoryResource/Pages/EditCategory.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Resources\CategoryResource\Pages;
|
||||
|
||||
use App\Admin\Resources\CategoryResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditCategory extends EditRecord
|
||||
{
|
||||
protected static string $resource = CategoryResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make()->before(function (Actions\DeleteAction $action) {
|
||||
if ($this->record->products()->exists() || $this->record->children()->exists()) {
|
||||
Notification::make()
|
||||
->title('Cannot delete category')
|
||||
->body('The category has products or children categories.')
|
||||
->duration(5000)
|
||||
->icon('ri-error-warning-line')
|
||||
->danger()
|
||||
->send();
|
||||
$action->cancel();
|
||||
}
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Resources\CategoryResource\Pages;
|
||||
|
||||
use App\Admin\Resources\CategoryResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListCategories extends ListRecords
|
||||
{
|
||||
protected static string $resource = CategoryResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user