Extensibility & Customization
Sanchaya resolves its main behavior from configuration, so production apps can replace the default Eloquent models, authorization policy, and file-operation action classes without editing package files.
Replace Models and Policy
Use custom models when you need extra casts, relationships, scopes, observers, or table names. Extend the package models so the file manager keeps the expected relationships and helpers.
// config/filament-sanchaya.php
'model' => \App\Models\MediaFile::class,
'attachment_model' => \App\Models\MediaAttachment::class,
'policy' => \App\Policies\MediaFilePolicy::class,namespace App\Models;
use DP0\Sanchaya\Models\SanchayaFile;
class MediaFile extends SanchayaFile
{
protected $table = 'sanchaya_files';
protected $casts = [
'metadata' => 'array',
];
}When both default models are replaced, publish and own the migrations in your application. Sanchaya only auto-loads package migrations for the default file or attachment models.
Override Action Classes
Each configured action is resolved from Laravel's container. Create a class with the same public method contract as the action you are replacing; extending the shipped class is the safest starting point.
// config/filament-sanchaya.php
'actions' => [
'delete' => [
'enabled' => true,
'label' => 'Delete',
'icon' => 'heroicon-m-trash',
'class' => \App\Actions\MyCustomDeleteAction::class,
],
],namespace App\Actions;
use DP0\Sanchaya\Actions\DeleteAction;
use DP0\Sanchaya\Models\SanchayaFile;
class MyCustomDeleteAction extends DeleteAction
{
public function execute(SanchayaFile $item): bool
{
// Add audit logging, external cleanup, or business checks here.
return parent::execute($item);
}
}| Config key | Default class | Methods used by the manager |
|---|---|---|
actions.download.class | DownloadAction | execute($file), bulk($items) |
actions.create_folder.class | CreateFolderAction | execute($name, $disk, $parentId) |
actions.rename.class | RenameAction | execute($item, $newName) |
actions.move.class | MoveAction | execute($item, $destinationId, $destinationDisk) |
actions.copy.class | CopyAction | execute($item, $destinationId, $destinationDisk) |
actions.delete.class | DeleteAction | execute($item), bulk($items), restore($item), forceDeleteTrashed($item) |
The preview action has configurable visibility, label, and icon, but it does not resolve a backend action class.