PHP code example of abianbiya / filehandler

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

    

abianbiya / filehandler example snippets


public function canAccessFile() : array|bool
{
	// do some complicated checking algorithm to authorized role or file ownership
	// you may use Auth::user(), or $this->created_by to check this model record's owner, or whatever
	return $allowAccess; // returning boolean
	// OR
	return [$allowAccess, 'Such a denied message to show in a 403 page']; // returning array (default message: Forbidden.)
}
 php
	$model->addFileFromRequest('fieldname', 'foldername')->save();
	
 php
$model->addFileFromPath('path', 'foldername')->save();
 php
$model->disk('local')->setProperties($array)->replace()->addFileFrom
 php
$data['yuhu'] = Model::with('file')->whateverQueryYouWant();
 bash
$ php artisan vendor:publish --tag=filehandler.assets