Laravel Artifact is a lightweight package for simple media management in Laravel. It streamlines file uploads, storage, retrieval, and supports public/private disks and signed URLs.
use LaravelJutsu\Artifact\Concerns\HasArtifacts;use Illuminate\Database\Eloquent\Model; class User extends Model{ use HasArtifacts; // Single file relationship public function avatar() { return $this->singleArtifact('avatar'); } // Multiple files relationship public function documents() { return $this->manyArtifacts('documents'); }}
After you define relationships on your model(s), uploading and accessing files becomes straightforward using the package's API. Whether you need to store multiple files at once or just one, the package offers a simple solution:
// Store a single file (one-to-one)$artifact = $user->avatar()->store($file); // Store multiple files (one-to-many)$artifacts = $user->documents()->store(request()->file('documents')); // Specify storage disk$artifact = $user->avatar()->store($file); // Uses default disk$artifacts = $user->documents()->store($files, 'public'); // Access$avatar = $user->avatar;$avatar->rawUrl();$avatar->rawUrl();$avatar->streamUrl();$avatar->signedUrl();$avatar->temporarySignedUrl(60);
Main Features
- Simple file upload and storage management
- Support for multiple storage disks (local, S3, etc.)
- Automatic deduplication to prevent duplicate files
- Signed URLs for secure file access
- Clean one-to-one and one-to-many file relationships
- Automatic metadata tracking (filename, MIME type, size)
🧑💻 You can get started with this package on GitHub: ludoguenet/laravel-artifact