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

62 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 Slider extends Model
{
use LogsActivity, LogOptionsTrait;
protected $fillable = [
'name',
'image',
'language',
'link',
'type',
'views',
'placement',
'published',
'position'
];
protected $casts = [
'published' => 'boolean'
];
protected static $logName = 'sliders';
protected static $logOnlyDirty = true;
protected static $submitEmptyLogs = false;
protected static $logAttributes = [
'name',
'image',
'language',
'link',
'type',
'placement',
'published',
'position'
];
public function getImage(): string
{
if (!empty($this->image)) {
if (in_array(env('FILESYSTEM_DISK'), ['s3', 'minio'])) {
return Storage::url($this->image);
}
return $this->image;
}
return '/images/nophoto.jpg';
}
public function scopePublished($query)
{
return $query->where('published', true);
}
}