raggitech/laravel-uploader

Laravel Uploader to upload files and handling visibility.

1.0.1 2020-03-13 16:41 UTC

This package is auto-updated.

Last update: 2020-07-13 17:16:26 UTC


README

Latest Stable Version Total Downloads License

Laravel Uploader provides a quick and easy methods to upload files and handling visibility with simple routing.

Install

Install the latest version using Composer:

$ composer require raggitech/laravel-uploader

then publish the migration & config files

$ php artisan vendor:publish --tag=laravel-uploader
$ php artisan migrate

Usage

Configurations / Options

/**
*	prefix 		=> Hash Prefix
*	visitable	=> Visits Counter
*	private		=> Only Permitted Users
*/

Uploading & Getting

function upload(UploadedFile $file, array $options = [])
function getUpload(string $hash)
// Upload File
$file = upload($request->image, [
	'visitable'	=> true
]);

// Getting Uploaded File with Hash code
$file = getUploaded('5e63885fa771d1.12185481920ncF3...');

// Information
echo $file->hash; // File's Hash
echo $file->name; // File's Name
echo $file->path; // File's Path
echo $file->size; // File's Size in Bytes
echo $file->readableSize(); // File's Readable Size
echo $file->extension; // File's Extension
echo $file->mime; // File's MIME

echo $file->visits; // File's visits (Visitable File)

URL & Uploader

echo $file->url(); // Getting Uploaded File's URL
// <img src"{{ $file->url() }}" alt="{{ $file->name }}">

$user = $file->uploader; // Getting Uploader's Model

Deleting Uploaded File

$file->delete();

Permits (Private File)

$permits = $file->permits; // Getting Permits List
$permitted = $file->isPermitted($user); // Checking if permitted (App\User)

$file->permit($user, '2021-02-01'); // Permitting a user
$file->forbid($user); // Forbidding a user

License

MIT license