PHP code example of abdelrahmanbl / laravel-uploadable
1. Go to this page and download the library: Download abdelrahmanbl/laravel-uploadable 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/ */
abdelrahmanbl / laravel-uploadable example snippets
php artisan storage:link
use Bl\LaravelUploadable\Interfaces\UploadFileInterface;
use Illuminate\Http\UploadedFile;
class CustomDriverService implements UploadFileInterface
{
protected $disk;
/**
* __construct
*
* @param \Bl\LaravelUploadable\Classes\FileArgument $disk
* @return void
*/
public function __construct($disk)
{
$this->disk = $disk->getValue();
}
/**
* handle store proccess of the file.
*
* @param UploadedFile $file
* @param string $directory
* @return mixed
*/
public function store(UploadedFile $file, string $directory): mixed
{
// ...
}
/**
* handle getting the file full url path.
*
* @param string $path
* @return string
*/
public function get(string $path): mixed
{
// ...
}
/**
* handle deleting a file.
*
* @param string $path
* @return void
*/
public function delete(string $path): void
{
// ...
}
}
use Illuminate\Http\UploadedFile;
class User extends model
{
/**
* Apply before the file cast upload event.
*
* @param UploadedFile $file
* @return UploadedFile
*/
public function beforeFileCastUpload(UploadedFile $file): UploadedFile
{
return $file;
}
/**
* Apply after the file cast upload event.
*
* @param UploadedFile $file
* @return void
*/
public function afterFileCastUpload(UploadedFile $file): void
{
dd($file);
}
}
use Bl\LaravelUploadable\Interfaces\EventUploadInterface;
use Illuminate\Http\UploadedFile;
class CustomUploadService implements EventUploadInterface
{
/**
* Apply before the file cast upload event.
*
* @param UploadedFile $file
* @return UploadedFile
*/
public function before(UploadedFile $file): UploadedFile
{
return $file;
}
/**
* Apply after the file cast upload event.
*
* @param UploadedFile $file
* @return void
*/
public function after(UploadedFile $file): void
{
dd($file);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.