add shipping rules

This commit is contained in:
Ludovic CANDELLIER
2023-07-16 14:45:42 +02:00
parent 72a7b270f9
commit 0879b0abf0
459 changed files with 6219 additions and 5416 deletions

View File

@@ -2,7 +2,6 @@
namespace App\Repositories\Core;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Intervention\Image\Facades\Image as Image;
@@ -14,6 +13,7 @@ class Upload
$data['filetype'] = $file->getClientOriginalExtension();
$data['filesize'] = $file->getSize();
$data['mime'] = $file->getMimeType();
return $data;
}
@@ -23,6 +23,7 @@ class Upload
$pos = strrpos($file, '/');
$uuid = substr($file, $pos + 1);
$uuid = pathinfo($uuid, PATHINFO_FILENAME);
return $uuid;
}
@@ -35,6 +36,7 @@ class Upload
// $path = $request->file('avatar')->storeAs('avatars',$request->user()->id,'s3');
// $path = $request->file('avatar')->storePublicly('avatars', 's3');
$request = Request();
return $request->has($var) ? basename($request->file($var)->store($path)) : false;
}
@@ -55,6 +57,7 @@ class Upload
{
$thumb = self::getThumbPath($file, $sub);
$filename = self::getPublicPath($file);
return Image::make($filename)->orientate()->widen($size)->save($thumb);
}
@@ -63,49 +66,52 @@ class Upload
return 'public/' . self::getFilename($file);
}
*/
public static function getPublicPath($file)
{
return storage_path('app/public/' . self::getFilename($file));
return storage_path('app/public/'.self::getFilename($file));
}
public static function getPrivatePath($file)
{
return storage_path('app/' . self::getFilename($file));
return storage_path('app/'.self::getFilename($file));
}
public static function getSrc($file)
{
return '/storage/' . self::getFilename($file);
return '/storage/'.self::getFilename($file);
}
public static function getThumbPath($file)
{
return storage_path('app/public/' . self::getThumbFilename($file));
return storage_path('app/public/'.self::getThumbFilename($file));
}
public static function getThumbSrc($file)
{
return '/storage/' . self::getThumbFilename($file);
return '/storage/'.self::getThumbFilename($file);
}
public static function getFilename($file)
{
$file = (is_array($file)) ? (object) $file : $file;
return $file->filepath . '/' . self::getName($file);
return $file->filepath.'/'.self::getName($file);
}
public static function getThumbFilename($file, $sub = false)
{
$sub = $sub ? $sub : 'thumbs/';
$file = (is_array($file)) ? (object) $file : $file;
return $file->filepath . '/' . $sub . self::getName($file);
return $file->filepath.'/'.$sub.self::getName($file);
}
public static function getName($file)
{
$file = (is_array($file)) ? (object) $file : $file;
return $file->uuid . '.' . strtolower($file->filetype);
return $file->uuid.'.'.strtolower($file->filetype);
}
/**
@@ -116,9 +122,10 @@ class Upload
*/
public static function fix($path)
{
if (!self::isWindows()) {
if (! self::isWindows()) {
return $path;
}
return str_replace('/', '\\', $path);
}
@@ -127,6 +134,7 @@ class Upload
if (Storage::exists($dest)) {
self::delete($dest);
}
return Storage::move($source, $dest);
}
@@ -144,9 +152,9 @@ class Upload
{
return is_dir($path) || mkdir($path, $permissions, true);
}
public static function isWindows()
{
return (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN');
return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
}
}