56 lines
1.2 KiB
PHP
Executable File
56 lines
1.2 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)) {
|
|
return Storage::url($this->image);
|
|
}
|
|
|
|
return (string) 'images/nophoto.png';
|
|
}
|
|
}
|