vd/app/Models/Category/Category.php
2018-11-05 09:26:30 +08:00

40 lines
762 B
PHP

<?php
namespace App\Models\Category;
use App\Core\Model;
use Dipper\Foundation\Nestedset\NodeTrait;
class Category extends Model
{
use NodeTrait;
protected $table = 'categories';
protected $casts = [
'extend' => 'array',
];
/**
* Get the hidden attributes for the model.
*
* @return array
*/
public function getHidden()
{
return [$this->getLftName(), $this->getRgtName()];
}
/**
* 查询只包含特定类型的内容.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param mixed $type
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeOfType($query, $type)
{
return $query->where('type', $type);
}
}