Skip to content

laravel-enso/documents

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

348 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Documents

License Stable Downloads PHP Issues Merge 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:

Companion frontend package:

Contributions

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

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

About

Laravel Enso Document Uploader and Manager package, meant to help you attach, download, remove and keep track of the user's files

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages