38 lines
763 B
PHP
38 lines
763 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* @property int $id
|
|
* @property string $name
|
|
* @property string $slug
|
|
* @property bool $default
|
|
* @property bool $visible
|
|
*/
|
|
class Category extends Model
|
|
{
|
|
// use HasFactory;
|
|
|
|
protected $guarded = [];
|
|
protected $casts = [
|
|
'id' => 'integer',
|
|
'name' => 'string',
|
|
'slug' => 'string',
|
|
'priority' => 'integer',
|
|
'default' => 'bool',
|
|
'visible' => 'bool'
|
|
];
|
|
|
|
public function scopeVisibled(Builder $builder)
|
|
{
|
|
return $builder->where(function (Builder $query) {
|
|
$query->where('visible', true)
|
|
->orWhere('default', true);
|
|
});
|
|
}
|
|
|
|
}
|