Laravel EnsoLaravel Enso
Guide
Back End
Front End
GitHub
Guide
Back End
Front End
GitHub
  • Back End

    • Action Logger
    • Addresses
    • Algolia
    • Algolia Webshop
    • API
    • Audits
    • Avatars
    • Cache Chain
    • Calendar
    • Cargo Partner
    • Categories
    • Charts
    • CI/CD
    • Cli
    • CNP Validator
    • Comments
    • Commercial
    • Companies
    • Core
    • Countries
    • Currencies
    • Data Export
    • Data Import
    • Discounts
    • Documents
    • Dynamic Methods
    • EAV
    • Emag
    • Enums
    • Excel
    • Facebook
    • Files
    • Filters
    • Financials
    • Forms
    • Frisbo
    • Google
    • Helpers
    • Holidays
    • How-to
    • Image Transformer
    • Impersonate
    • Interactions
    • Inventory
    • IO
    • Localisation
    • Lockable Models
    • Logs
    • Measurement Units
    • Meili Search
    • Meili Search Webshop
    • Menus
    • Migrator
    • Monitored Emails
    • Notifications
    • Packaging Units
    • PDF
    • People
    • Permissions
    • Product Eav
    • Product Lots
    • Products
    • Questionnaires
    • Rememberable
    • Roles
    • Sale Channels
    • Searchable
    • Select
    • Sentry
    • Services
    • Smart Bill
    • Sms Advert
    • Stripe
    • Tables
    • Tasks
    • Teams
    • Ticketing
    • Track Who
    • Tutorials
    • Typesense
    • Typesense Webshop
    • Unit Conversion
    • Upgrade
    • UPS
    • User Groups
    • Users
    • Versions
    • Virtual Call Center
    • Vouchers
    • Webshop
    • Webshop Commercial

Documents

LicenseStableDownloadsPHPIssuesMerge Requests

Description

Documents adds polymorphic document attachments to Enso models.

The package stores uploaded documents through the Enso files layer, exposes document listing, upload, and delete endpoints, supports configurable deletion rules for related models, and can queue OCR for PDF documents whose owners implement the Ocrable contract.

It is meant for backoffice models that need a lightweight document vault with optional OCR processing.

Installation

Install the package:

composer require laravel-enso/documents

Run the package migrations:

php artisan migrate

Optional publish:

php artisan vendor:publish --tag=documents-config

Default configuration:

return [
    'deletableTimeLimit' => 60 * 60,
    'imageWidth' => 2048,
    'imageHeight' => 2048,
    'onDelete' => 'restrict',
    'loggableMorph' => [
        'documentable' => [],
    ],
    'queues' => [
        'ocr' => 'heavy',
    ],
];

Features

  • Polymorphic one-to-one and one-to-many document relations via the Documentable trait.
  • File attachment handling through laravel-enso/files.
  • Upload, list, and delete API under core.documents.
  • Configurable delete policy with restrict or cascade.
  • OCR dispatch for PDF documents whose owner implements Ocrable.

Usage

Add the trait to any model that should own documents:

use Illuminate\Database\Eloquent\Model;
use LaravelEnso\Documents\Traits\Documentable;

class Order extends Model
{
    use Documentable;
}

Available relations:

  • document()
  • documents()

If the owning model should trigger OCR for uploaded PDFs, implement LaravelEnso\Documents\Contracts\Ocrable.

API

HTTP routes

  • GET api/core/documents
  • POST api/core/documents
  • DELETE api/core/documents/{document}

Route names:

  • core.documents.index
  • core.documents.store
  • core.documents.destroy

Model surface

LaravelEnso\\Documents\\Models\\Document

Useful methods:

  • store(array $request, array $files)
  • scopeFor(array $params): Builder
  • scopeFilter(?string $search): Builder

Depends On

Required Enso packages:

  • laravel-enso/core ↗
  • laravel-enso/files ↗
  • laravel-enso/helpers ↗
  • laravel-enso/image-transformer ↗
  • laravel-enso/migrator ↗
  • laravel-enso/ocr ↗
  • laravel-enso/track-who ↗
  • laravel-enso/users ↗

Companion frontend package:

  • @enso-ui/documents ↗

Contributions

are welcome. Pull requests are great, but issues are good too.

Thank you to all the people who already contributed to Enso!

Edit this page on GitHub
Last Updated: 4/20/2026, 3:07:12 PM
Prev
Discounts
Next
Dynamic Methods