storage url o'zgartirildi
This commit is contained in:
32
app/Support/Uploads.php
Normal file
32
app/Support/Uploads.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use RuntimeException;
|
||||
|
||||
class Uploads
|
||||
{
|
||||
public static function store(UploadedFile $file, string $path, ?string $disk = null): string
|
||||
{
|
||||
$storedPath = $disk ? $file->store($path, $disk) : $file->store($path);
|
||||
|
||||
if (!$storedPath) {
|
||||
throw new RuntimeException("File upload failed: {$path}");
|
||||
}
|
||||
|
||||
return $storedPath;
|
||||
}
|
||||
|
||||
public static function put(string $path, string $contents, ?string $disk = null): void
|
||||
{
|
||||
$stored = $disk
|
||||
? Storage::disk($disk)->put($path, $contents)
|
||||
: Storage::put($path, $contents);
|
||||
|
||||
if (!$stored) {
|
||||
throw new RuntimeException("File upload failed: {$path}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user