Has-Images is a package that provides a quick and easy way to link images with a model through images key for Laravel.
This package depends on Uploader.
Install the latest version using Composer.
1composer require pharaonic/laravel-has-images
2php artisan migrate
Images uploading is gonna be easiest thing you will think about, so you will be able to store, retrieve, update and delete images so easily.
You have to include HasImages trait into your model first.
Optional : You can customize the uploading options through Uploader.
6class Article extends Model
8 use HasImages;
10 protected $filesOptions = [ ...
11 'images' => [
12 'directory' => '/articles/images',
13 'thumbnail' => [
14 'ratio' => true,
15 'width' => 400,
16 'height' => null
This is how you can store images into your model, you can do that on create or add a single image to your model or even replace all the images with a new list of images.
1// On Create
2$article = Article::create([
3 'images' => [$request->file1, $request->file2, $request->file3]
6// Add Image
9// Replace All Images
10$article->images = [$request->file1, $request->file2, $request->file3];
It's an array of images so you can retrieve it easily or it's thumbnails too.
You can delete a single image or all images or the model with the images too.
1// Delete Single Image
4// Delete All Images
7// Delete Model With It's Images too
You can publish the migrations.
1php artisan vendor:publish --tag=laravel-has-images