PHP code example of sabbir268 / laravel-filecaster
1. Go to this page and download the library: Download sabbir268/laravel-filecaster 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/ */
use App\Models;
use Sabbir268\LaravelFileCaster\FileCaster;
class Blog extends Model
{
// ...
protected $casts = [
'image' => FileCaster::class,
];
// ...
}
use App\Models;
class Blog extends Model
{
// ...
protected $casts = [
'image' => 'filecast',
];
// ...
}
$blog = new Blog();
$blog->image = $request->file('image');
$blog->save();