Files
getgreen-backend/app/Models/SpecialOffer.php
2026-04-16 04:05:10 +05:00

59 lines
1.3 KiB
PHP
Executable File

<?php
namespace App\Models;
use App\Traits\LogOptionsTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Date;
use Illuminate\Support\Facades\Storage;
use Spatie\Activitylog\Traits\LogsActivity;
class SpecialOffer extends Model
{
use LogsActivity, LogOptionsTrait;
protected $fillable = [
'name',
'description',
'link',
'image'
];
protected $casts = [
'name' => 'array',
'description' => 'array'
];
protected static $logName = 'special_offer';
protected static $logOnlyDirty = true;
protected static $submitEmptyLogs = false;
protected static $logAttributes = [
'name',
'description',
'link',
'image'
];
public function getName(): string
{
return (string) $this->name[app()->getLocale()] ?? null;
}
public function getDescription(): string
{
return (string) $this->description[app()->getLocale()] ?? null;
}
public function getImage(): string
{
if (!empty($this->image)) {
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
return Storage::url($this->image);
}
return (string) $this->image;
}
return (string) 'images/nophoto.png';
}
}