PHP code example of elvin-qulizade / filament-versions

1. Go to this page and download the library: Download elvin-qulizade/filament-versions 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/ */

    

elvin-qulizade / filament-versions example snippets


return [
    // Attributes never stored in a version snapshot, on top of any
    // model-level $versionExcept property.
    'excluded_attributes' => [
        'password',
        'remember_token',
        'created_at',
        'updated_at',
    ],

    // Maximum number of versions kept per model instance. Older versions
    // are pruned automatically after each save, and via `versions:prune`.
    'max_versions_per_model' => 50,

    // Optional callable(Version $version): bool to gate the "Restore" action.
    // Left null, restoring is allowed for anyone who can see the History tab.
    'authorize_restore' => null,

    // Global retroactive cleanup, on top of the automatic per-save pruning
    // above. Off by default since per-save pruning already keeps storage
    // bounded for new versions.
    'schedule' => [
        'enabled' => false,
        'cron' => '0 3 * * *',
    ],
];

use ElvinQulizade\Versions\Concerns\HasVersions;
use ElvinQulizade\Versions\Contracts\Versionable;

class Post extends Model implements Versionable
{
    use HasVersions;
}

use ElvinQulizade\Versions\Filament\RelationManagers\VersionsRelationManager;

public static function getRelations(): array
{
    return [
        VersionsRelationManager::class,
    ];
}
css
@source '../../../../vendor/elvin-qulizade/filament-versions/resources/**/*.blade.php';
bash
php artisan vendor:publish --tag="filament-versions-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="filament-versions-config"
bash
php artisan vendor:publish --tag="filament-versions-views"
bash
php artisan versions:prune
php artisan versions:prune --model="App\Models\Post" --keep=20