lee-to / pixel-craft
Laravel route image generator
1.0.1
2024-06-19 07:25 UTC
Requires
- php: ^8.0|^8.1|^8.2|^8.3
- intervention/image: ^2.7
Requires (Dev)
- mockery/mockery: ^1
- phpunit/phpunit: ^10
This package is auto-updated.
Last update: 2024-12-19 08:31:34 UTC
README
PixelCraft
Image generator via router in Laravel
Installation
composer require lee-to/pixel-craft
php artisan vendor:publish --provider="Leeto\PixelCraft\PixelCraftServiceProvider"
Usage
1. Set disk and available sized in config
2. Add trait HasGeneratedImage to Model
<?php namespace App\Models; use Leeto\PixelCraft\Traits\HasGeneratedImage; use Illuminate\Database\Eloquent\Model; class Article extends Model { use HasGeneratedImage; // .. protected function imageDir(): string { return 'articles'; } protected function imageColumn(): string { return 'thumbnail'; } // .. }
3. Get image
$model->makeImage('200x200')
$model->makeImages('200x200')
$model->makeImage('200x200', 'fit')