Installation
How to install OI Laravel Attachments via Composer
Installation
Via Composer
composer require oi-lab/oi-laravel-attachmentsThe package auto-discovers and registers its service provider via Laravel's package discovery — no manual registration required.
Publish the migrations
The package ships the folders, files, and attachments migrations. Publish them into your application and run them:
php artisan vendor:publish --tag=oi-laravel-attachments-migrations
php artisan migrateThe migrations are also loaded automatically from the package, so
php artisan migrateworks even without publishing. Publish them only when you need to customize the schema.
Publish the configuration (optional)
php artisan vendor:publish --tag=oi-laravel-attachments-configThis creates config/oi-laravel-attachments.php with sensible defaults. See Configuration for all available options.
Local development
To use the package from a local checkout alongside your project, add a path repository to your project's composer.json:
{
"repositories": [
{
"type": "path",
"url": "./packages/oi-lab/oi-laravel-attachments"
}
]
}Then require it:
composer require oi-lab/oi-laravel-attachmentsVerify the installation
Add the HasAttachments trait to a model and attach a file to confirm the wiring:
use OiLab\OiLaravelAttachments\Concerns\HasAttachments;
use OiLab\OiLaravelAttachments\Models\File;
class Product extends Model
{
use HasAttachments;
}
$product->attachFile(File::first());
$product->attachments; // should contain one attachment