PHP code example of konnco / laravel-imagecast

1. Go to this page and download the library: Download konnco/laravel-imagecast 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/ */

    

konnco / laravel-imagecast example snippets


return [
    'disk' => env('IMAGECAST_DISK', 'public'),
    'path' => 'images',
    'blurhash' => env('IMAGECAST_BLURHASH', false)
];

use Konnco\ImageCast\Casts\Image;

protected $casts = [
    'avatar' => Image::class,
];

protected $casts = [
    'avatar' => Image::class.":80,images/account/avatar,jpg",
    'banner' => Image::class.":80,images/account/avatar,png",
];

protected $casts = [
    'avatar' => Image::class.":80,images/account/avatar/{date:Y-m-d},jpg",
];

$user = New User();
$user->name = $request->name;
$user->avatar = $request->photo;
$user->save();

use Konnco\ImageCast\ImageCastExceptionHandler;

public function render($request, Throwable $exception) {
    return new ImageCastExceptionHandler($exception, request()->url(), function(){
        return parent::render($request, $exception);
    });
}

return $user->avatar->toUrl();

return $user->avatar->toBase64();
bash
php artisan vendor:publish --provider="Konnco\ImageCast\ImageCastServiceProvider" --tag="laravel-imagecast-config"