1. Go to this page and download the library: Download bnhashem/file 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 Bnhashem\File\Traits\File;
public function store(Request $request)
{
$post = new Post([
'image' => File::store('posts' , 'image'),
'banner' => File::store('posts' , 'banner'),
]);
$post->save();
// posts is the parent Folder
// image and banner are the childs Folders
// image and banner also request name , that mean image or banner is
use Bnhashem\File\Traits\File;
public function update(Request $request , Post $post)
{
$post->update([
'image' = File::update('posts' , 'image' , $post),
'banner' = File::update('posts' , 'banner' , $post),
]);
// posts are the parent Folder
// image and banner are the childs Folders
// image and banner also request name , that mean image or banner is
use Bnhashem\File\Traits\File;
public function destroy(Request $request , Post $post)
{
File::destroy('image' , $post);
File::destroy('banner' , $post);
// You should pass Row to function
}