Image Helpers
<?php
namespace App\Helpers;
use Illuminate\Support\Str;
class ImageHelper
{
/*
|--------------------------------------------------------------------------
| Image Helper
|--------------------------------------------------------------------------
|
| This helper is used for image related data.
| This helper contain methods that upload and resize images.
|
*/
/**
* This method is used for save Image.
*
* @param file $image
* @param URL $path
* @param string $filePrefix
*
* @return void
*/
public static function imageSave($image, $path, $filePrefix)
{
if(!empty($image)) {
$destinationPath = public_path($path);
$fileName = $filePrefix.'_'.time().'_'.strtolower(Str::random(6) ).'.'.$image->getClientOriginalExtension();
if($image->move($destinationPath, $fileName)) {
chmod($destinationPath.'/'.$fileName,0777);
return $fileName;
}
}
return null;
}
}
Comments
Post a Comment