PHP code example of monurakkaya / laravel-image

1. Go to this page and download the library: Download monurakkaya/laravel-image library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

monurakkaya / laravel-image example snippets


    public function boot()
    {
        Model::observe(Monurakkaya\LaravelImage\Observers\ImageObserver);
    }

    class Gallery extends Model {
    
        protected $poster = [
            'width' => 800,
            'height' => 800 
        ];
        
        protected $thumbnail = false; // Package won't generate a thumbnail for uploaded images.
    }

    $gallery = Gallery::with('images')->first();
    $gallery->images; //returns image collection.

    $image = $gallery->images()->first();
    $gallery->makeDefault($image);

    $gallery = Gallery::with('defaultImage')->first();
    $gallery->defaultImage; //returns image model

    $gallery->removeImage($image)

    @laravelImage([
        'model' => $gallery
    ])
    @endlaravelImage

php artisan vendor:publish --tag=laravel-image
php artisan migrate