PHP code example of matchingood / laravel-eloquent-storage
1. Go to this page and download the library: Download matchingood/laravel-eloquent-storage 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/ */
matchingood / laravel-eloquent-storage example snippets
$file = $request->file('file');
$userFile = new UserFile;
$userFile->saveFromUploadedFile($file);
$userFile->getContent(); // the content in the $file
// original file name
$table->string('file_name');
// unique file name to avoid conflicting original names
$table->string('unique_file_name');
// directory to store directory information
// for using directory parameters on saveConent or saveUploadedFile
$table->string('directory');
class UserFile extends MatchinGood\EloquentStorage\EloquentStorage
{
}
$userFile = new UserFile;
// 1. store text
$userFile->saveContent('file name', 'content');
// 2. store uploaded file
$file = $request->file('file');
$userFile->saveFromUploadedFile($file);
// you can add root directory like below
// in this case with local driver,
// it's gonna be stored at storage/app/root/user_files/xxxxxx
$userFile->saveFromUploadedFile($file, 'root');