PHP code example of mansoor / filament-versionable
1. Go to this page and download the library: Download mansoor/filament-versionable library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mansoor / filament-versionable example snippets
use Overtrue\LaravelVersionable\VersionStrategy;
class Post extends Model
{
use Overtrue\LaravelVersionable\Versionable;
protected $versionable = ['title', 'content'];
protected $versionStrategy = VersionStrategy::SNAPSHOT;
}
namespace App\Filament\Resources\ArticleResource\Pages;
use App\Filament\Resources\ArticleResource;
use Mansoor\FilamentVersionable\RevisionsPage;
class ArticleRevisions extends RevisionsPage
{
protected static string $resource = ArticleResource::class;
}
use App\Filament\Resources\ArticleResource\Pages;
public static function getPages(): array
{
return [
...
'revisions' => Pages\ArticleRevisions::route('/{record}/revisions'),
];
}
use Mansoor\FilamentVersionable\Page\RevisionsAction;
protected function getHeaderActions(): array
{
return [
RevisionsAction::make(),
];
}
use Mansoor\FilamentVersionable\Table\RevisionsAction;
$table->actions([
RevisionsAction::make(),
]);
class ArticleRevisions extends RevisionsPage
{
protected static string $resource = ArticleResource::class;
public function shouldStripTags(): bool
{
return true;
}
}