Search by

artisan-toolbox / filoquent

allanivp

Preview foundations for connecting Laravel's filesystem to Eloquent model attributes.

Package info

github.com/artisan-toolbox/filoquent

pkg:composer/artisan-toolbox/filoquent

Statistics

Installs: 37

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 1

1.0.0-beta.6 2026-11-18 22:14 UTC

This package is auto-updated.

Last update: 2026-11-19 23:36:07 UTC


README

Filoquent

version Packagist PHP Laravel Tests Docs

File attributes for Eloquent with upload variants and indexed storage ownership.

Filoquent connects Laravel filesystems to Eloquent attributes. Assign an uploaded file, local path, or stream, then save the model. Middleware can produce named variants. An indexed ownership ledger coordinates replacement and permanent deletion.

Filoquent is in beta, and its public API may change before the first stable release. The consolidated migration requires a database that has never run Filoquent migrations. Check the installation guide before upgrading an existing database. For a new installation, run these commands from your Laravel application root.

composer require 'artisan-toolbox/filoquent:@beta'
php artisan migrate

Add a nullable JSON column using $table->filoquent('attachment')->nullable() and configure its model:

use ArtisanToolbox\Filoquent\Casts\AsFile;
use ArtisanToolbox\Filoquent\Concerns\HasFiloquent;
use Illuminate\Database\Eloquent\Model;

class Document extends Model
{
    use HasFiloquent;

    protected function casts(): array
    {
        return ['attachment' => AsFile::class];
    }
}

$source = storage_path('app/filoquent-example.txt');
file_put_contents($source, 'Hello Filoquent');

$document = new Document;
$document->attachment = $source;
$document->save();

dump($document->attachment->default()->exists());

The dump is true.

Run the installation guide to create the example table and configure writable storage. File metadata retains its saved disk and path across cast changes. Soft deletes retain files. The garbage collector reconciles committed receipts after manual row or column deletion. Optional Redis recovery tracks interrupted writes. Objects without a SQL receipt or Redis intent remain outside automatic discovery.

Read the documentation, contributing guide, security policy, changelog, and MIT license.