🆙 More fixes 🆙

This commit is contained in:
Remco
2026-01-19 20:43:46 +01:00
parent deed2158ca
commit 7b9849c159
77 changed files with 1084 additions and 13612 deletions
+13 -7
View File
@@ -4,35 +4,41 @@ namespace App\Models;
use App\Services\SettingsService;
use Exception;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Storage;
/**
* @property string $image
*/
class WebsiteAd extends Model
{
use HasFactory;
protected $fillable = [
'image',
];
/**
* @return \Illuminate\Database\Eloquent\Casts\Attribute<string, never>
*/
protected function imageUrl(): \Illuminate\Database\Eloquent\Casts\Attribute
{
return \Illuminate\Database\Eloquent\Casts\Attribute::make(get: function () {
$settingsService = app(SettingsService::class);
/** @var string $adsPicturePath */
$adsPicturePath = Cache::remember('ads_picture_path', 3600, fn () => $settingsService->getOrDefault('ads_picture_path'));
if (! str_starts_with((string) $adsPicturePath, 'http')) {
$adsPicturePath = rtrim((string) config('app.url'), '/') . '/' . ltrim((string) $adsPicturePath, '/');
if (! str_starts_with($adsPicturePath, 'http')) {
$adsPicturePath = rtrim((string) config('app.url'), '/') . '/' . ltrim($adsPicturePath, '/');
}
return rtrim((string) $adsPicturePath, '/') . '/' . $this->image;
return rtrim($adsPicturePath, '/') . '/' . $this->image;
});
}
#[\Override]
protected static function booted()
{
static::deleting(function ($websiteAd): void {
static::deleting(function (WebsiteAd $websiteAd): void {
try {
$websiteAd->configureAdsDisk();