2.x - php

This commit is contained in:
Saeed Vaziry
2024-09-28 15:19:55 +02:00
parent f6bc04763b
commit 32993025de
21 changed files with 698 additions and 83 deletions

View File

@ -2,11 +2,13 @@
namespace App\Models;
use Exception;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Symfony\Component\HttpFoundation\StreamedResponse;
/**
* @property int $server_id
@ -46,7 +48,7 @@ public static function boot(): void
if (Storage::disk($log->disk)->exists($log->name)) {
Storage::disk($log->disk)->delete($log->name);
}
} catch (\Exception $e) {
} catch (Exception $e) {
Log::error($e->getMessage(), ['exception' => $e]);
}
});
@ -67,6 +69,11 @@ public function site(): BelongsTo
return $this->belongsTo(Site::class);
}
public function download(): StreamedResponse
{
return Storage::disk($this->disk)->download($this->name);
}
public static function getRemote($query, bool $active = true, ?Site $site = null)
{
$query->where('is_remote', $active);