lee-to/pixel-craft

Laravel route image generator

1.0.1 2024-06-19 07:25 UTC

This package is auto-updated.

Last update: 2024-10-19 08:09:07 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')