36 lines
722 B
PHP
36 lines
722 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Enums\IsShow;
|
|
use Illuminate\Database\Eloquent\Attributes\Scope;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class Testimonial extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'is_show' => IsShow::class,
|
|
];
|
|
}
|
|
|
|
#[Scope]
|
|
public function show(Builder $query): void
|
|
{
|
|
$query->where('is_show', IsShow::SHOW);
|
|
}
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
}
|