62 lines
1.3 KiB
PHP
Executable File
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);
|
|
}
|
|
}
|