PHP code example of okeonline / filament-archivable

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

    

okeonline / filament-archivable example snippets


class AppPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            // ...
            ->plugin(\Okeonline\FilamentArchivable\FilamentArchivablePlugin::make());
    }
}


use Okeonline\FilamentArchivable\Tables\Actions\ArchiveAction;
use Okeonline\FilamentArchivable\Tables\Actions\UnArchiveAction;
// ...

class UserResource extends Resource
{
    // ...
    public static function table(Table $table): Table
    {
        return $table
            // ...
            ->actions([
                ArchiveAction::make(),
                UnArchiveAction::make(),
            ]);
    }
}

ArchiveAction::make()
    ->hiddenLabel()
    ->tooltip('Archive'),

// in e.g. Filament/PostResource/EditPage.php
use Okeonline\FilamentArchivable\Actions\ArchiveAction;
use Okeonline\FilamentArchivable\Actions\UnArchiveAction;

// ...
protected function getHeaderActions(): array
{
    return [
        ArchiveAction::make(),
        UnArchiveAction::make(),
    ];
}

use Filament\Support\Enums\ActionSize;

ArchiveAction::make()
    ->color('success')
    ->size(ActionSize::Large),

use Okeonline\FilamentArchivable\Tables\Filters\ArchivedFilter;

public static function table(Table $table): Table
{
    return $table
        // ...
        ->filters([
            ArchivedFilter::make(),
        ]);
}

// in your resource:
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use LaravelArchivable\Scopes\ArchivableScope; 

public static function getEloquentQuery(): Builder
{
    return parent::getEloquentQuery()
        ->withoutGlobalScopes([
            SoftDeletingScope::class, // only if soft deleting is also active, otherwise it can be ommitted
            ArchivableScope::class,
        ]);
}

public static function table(Table $table): Table
{
    return $table
        ->archivedRecordClasses(['opacity-25']);
}
bash
php artisan vendor:publish --tag=filament-archivable-translations