finished the upgrade to filament 4. completely revamped the frontend with codex, now it looks great!
This commit is contained in:
24
app/Filament/Resources/Images/Pages/EditImage.php
Normal file
24
app/Filament/Resources/Images/Pages/EditImage.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ImageResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ImageResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditImage extends EditRecord
|
||||
{
|
||||
protected static string $resource = ImageResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('index');
|
||||
}
|
||||
}
|
||||
72
app/Filament/Resources/Images/Pages/ListImages.php
Normal file
72
app/Filament/Resources/Images/Pages/ListImages.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\ImageResource\Pages;
|
||||
|
||||
use App\Filament\Resources\ImageResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Contracts\Pagination\Paginator;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Filament\Notifications\Notification;
|
||||
|
||||
class ListImages extends ListRecords
|
||||
{
|
||||
protected static string $resource = ImageResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\Action::make('delete_all')
|
||||
->label('Delete All Images')
|
||||
->icon('heroicon-o-trash')
|
||||
->color('danger')
|
||||
->requiresConfirmation()
|
||||
->action(function () {
|
||||
// Delete all images from storage
|
||||
Storage::disk('public')->deleteDirectory('images');
|
||||
Storage::disk('public')->makeDirectory('images');
|
||||
|
||||
// Show success notification
|
||||
Notification::make()
|
||||
->title('All images deleted successfully')
|
||||
->success()
|
||||
->send();
|
||||
|
||||
// Refresh the page
|
||||
$this->redirect(static::getUrl());
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
protected function shouldPersistTableFiltersInSession(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function shouldPersistTableSortInSession(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function shouldPersistTableSearchInSession(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function paginateTableQuery(Builder $query): Paginator
|
||||
{
|
||||
$paginator = parent::paginateTableQuery($query);
|
||||
return $paginator;
|
||||
}
|
||||
|
||||
public function updatedTablePage($page)
|
||||
{
|
||||
$this->dispatch('table-pagination-updated', ['tableId' => $this->id, 'page' => $page]);
|
||||
}
|
||||
|
||||
protected function getTableQueryStringIdentifier(): ?string
|
||||
{
|
||||
return 'images-table';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user