main

filamentphp/demo

Last updated at: 29/12/2023 09:45

EditPost.php

TLDR

The file EditPost.php is a resource page for editing a blog post in the Filament package. It extends the EditRecord class and is associated with the PostResource resource.

Classes

EditPost

The EditPost class is a resource page that allows users to edit a blog post. It extends the EditRecord class provided by the Filament package. It is associated with the PostResource resource. The class includes the following methods:

  • getTitle(): This method returns the title of the blog post being edited. It is expected to return a string or an object implementing the Htmlable interface.

  • getActions(): This method returns an array of actions that can be performed on the blog post. In this case, it includes a DeleteAction to delete the post.

<?php

namespace App\Filament\Resources\Blog\PostResource\Pages;

use App\Filament\Resources\Blog\PostResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use Illuminate\Contracts\Support\Htmlable;

class EditPost extends EditRecord
{
    protected static string $resource = PostResource::class;

    public function getTitle(): string | Htmlable
    {
        return $this->record->title;
    }

    protected function getActions(): array
    {
        return [
            Actions\DeleteAction::make(),
        ];
    }
}