1. Go to this page and download the library: Download pfrug/file-upload 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/ */
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Pfrug\FileUpload\Traits\HasImageUploads;
class Post extends Model
{
use HasImageUploads;
protected $uploadableImages = [
'image',
'thumb'
];
public function store(Request $request)
{
// ... you code here, try-catch validate etc..
Post::create($request->all());
...
public function update(Request $request, Post $post)
// ... you code here, try-catch, validate data, etc..
$post->fill($request->all());
$post->save();