An expressive image helper for Laravel.
- Save / tag images against any model.
- Manipulate images on the fly.
- Install the package from composer
- Run the migration script
- Add the
HasModelImage
trait to your model, so for example, if you want to add avatar images to yourUser
model, add the following trait:
<?php
namespace App\Models;
use Barrydevt\Imagepal\Concerns\HasModelImages;
class User extends Authenticatable
{
use HasModelImages;
protected $images = [
'avatar' => [
'size' => [100,100]
]
];
- Save an avatar image with the image pal facade:
$user = User::find(1);
$user->images()->save('https://www.image.com/image.png');
- Now you have the image saved, you can use it in your blade templates:
<img src="{{ $user->images('avatar')->url }}" alt="{{ $user->images('avatar')->alt }}" />