Add (vite build)
This commit is contained in:
@@ -8,14 +8,12 @@
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Kalnoy\Nestedset\NodeTrait;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
|
||||
use Kalnoy\Nestedset\NodeTrait;
|
||||
|
||||
/**
|
||||
* Class Category
|
||||
*
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string|null $slug
|
||||
@@ -25,49 +23,45 @@
|
||||
* @property int $_lft
|
||||
* @property int $_rgt
|
||||
* @property int|null $parent_id
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class Category extends Model
|
||||
{
|
||||
use NodeTrait;
|
||||
use NodeTrait;
|
||||
|
||||
protected $table = 'categories';
|
||||
protected $table = 'categories';
|
||||
|
||||
protected $casts = [
|
||||
'enabled' => 'bool',
|
||||
'_lft' => 'int',
|
||||
'_rgt' => 'int',
|
||||
'parent_id' => 'int'
|
||||
];
|
||||
protected $casts = [
|
||||
'enabled' => 'bool',
|
||||
'_lft' => 'int',
|
||||
'_rgt' => 'int',
|
||||
'parent_id' => 'int',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'slug',
|
||||
'enabled',
|
||||
'_lft',
|
||||
'_rgt',
|
||||
'parent_id'
|
||||
];
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'slug',
|
||||
'enabled',
|
||||
'_lft',
|
||||
'_rgt',
|
||||
'parent_id',
|
||||
];
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::saved(function ($category) {
|
||||
if (empty($category->slug)) {
|
||||
$category->slug = Str::slug($category->name);
|
||||
$category->saveQuietly();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function saveQuietly(array $options = [])
|
||||
{
|
||||
return static::withoutEvents(function () use ($options) {
|
||||
return $this->save($options);
|
||||
});
|
||||
}
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::saved(function ($category) {
|
||||
if (empty($category->slug)) {
|
||||
$category->slug = Str::slug($category->name);
|
||||
$category->saveQuietly();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function saveQuietly(array $options = [])
|
||||
{
|
||||
return static::withoutEvents(function () use ($options) {
|
||||
return $this->save($options);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user