Skip to content

Instantly share code, notes, and snippets.

@ahmadshah
Created May 11, 2014 19:37
Show Gist options
  • Save ahmadshah/f1000eaebea0f9b7c37d to your computer and use it in GitHub Desktop.
Save ahmadshah/f1000eaebea0f9b7c37d to your computer and use it in GitHub Desktop.
UploadableTrait.php
<?php namespace Eisai\Support\Traits;
use Rhumsaa\Uuid\Uuid;
use Illuminate\Support\Facades\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
trait UploadableTrait {
/**
* [store description]
* @return [type] [description]
*/
public function move(UploadedFile $file)
{
$path = $this->getUploadPath();
$extension = $file->getClientOriginalExtension();
$filename = Uuid::uuid1().".{$extension}";
$file->move($path, $filename);
return $path."/{$filename}";
}
/**
* [delete description]
* @return [type] [description]
*/
public function remove($file)
{
return File::delete($file);
}
/**
* [setUploadPath description]
* @param [type] $path [description]
*/
protected function getUploadPath()
{
return public_path().'/uploads';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment