PHP code example of wezlo / filament-record-freezer
1. Go to this page and download the library: Download wezlo/filament-record-freezer 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/ */
wezlo / filament-record-freezer example snippets
use Wezlo\FilamentRecordFreezer\FilamentRecordFreezerPlugin;
public function panel(Panel $panel): Panel
{
return $panel
->plugins([
FilamentRecordFreezerPlugin::make(),
]);
}
use Wezlo\FilamentRecordFreezer\Concerns\HasFreezes;
class Contract extends Model
{
use HasFreezes;
}
$contract->freeze('Legal hold — case #4412'); // throws if already frozen
$contract->isFrozen(); // true
$contract->activeFreeze; // current Freeze row (or null)
$contract->freezes; // full history, newest first
$contract->unfreeze('Case closed — release'); // sets unfrozen_at, keeps history
$contract->freeze('Re-opened for audit'); // new Freeze row, history preserved
$contract->update(['amount' => 5000]); // → RecordFrozenException
$contract->delete(); // → RecordFrozenException
use Filament\Actions\DeleteAction;
use Filament\Actions\EditAction;
use Filament\Actions\ViewAction;
use Filament\Resources\Resource;
use Wezlo\FilamentRecordFreezer\Actions\FreezableActionGroup;
use Wezlo\FilamentRecordFreezer\Concerns\HandlesFrozenRecords;
class ContractResource extends Resource
{
use HandlesFrozenRecords;
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('title'),
static::freezableColumn(), // lock icon + tooltip
])
->recordActions([
ViewAction::make(), // always available
FreezableActionGroup::make()
->canFreeze(fn ($record) => auth()->user()->is_admin)
->canUnfreeze(fn ($record) => auth()->user()->hasRole('compliance'))
->unfrozenActions([
EditAction::make(), // auto-hidden when frozen
DeleteAction::make(), // auto-hidden when frozen
]),
]);
}
}
$contract->freezes; // full history, newest first
$contract->freezes->first()->frozen_by; // user id who froze
$contract->freezes->first()->unfrozenBy?->name; // who released it (if released)
$contract->freezes->first()->unfreeze_reason; // why it was released
$contract->activeFreeze; // current Freeze row (null if not frozen)