X7ROOT File Manager
Current Path:
/home/gfecatvj/sites/realesbar/platform/plugins/blog/src/Models
home
/
gfecatvj
/
sites
/
realesbar
/
platform
/
plugins
/
blog
/
src
/
Models
/
📁
..
📄
Category.php
(1.84 KB)
📄
Post.php
(2.32 KB)
📄
Tag.php
(1.21 KB)
Editing: Category.php
<?php namespace Botble\Blog\Models; use Botble\Base\Traits\EnumCastable; use Botble\Base\Enums\BaseStatusEnum; use Botble\Slug\Traits\SlugTrait; use Botble\Base\Models\BaseModel; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\HasMany; class Category extends BaseModel { use SlugTrait; use EnumCastable; /** * The database table used by the model. * * @var string */ protected $table = 'categories'; /** * @var string */ protected $primaryKey = 'id'; /** * The date fields for the model.clear * * @var array */ protected $dates = [ 'created_at', 'updated_at', ]; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'description', 'parent_id', 'icon', 'is_featured', 'order', 'is_default', 'status', 'author_id', ]; /** * @var array */ protected $casts = [ 'status' => BaseStatusEnum::class, ]; /** * @return BelongsToMany */ public function posts(): BelongsToMany { return $this->belongsToMany(Post::class, 'post_categories')->with('slugable'); } /** * @return BelongsTo */ public function parent(): BelongsTo { return $this->belongsTo(Category::class, 'parent_id')->withDefault(); } /** * @return HasMany */ public function children(): HasMany { return $this->hasMany(Category::class, 'parent_id'); } protected static function boot() { parent::boot(); self::deleting(function (Category $category) { $category->posts()->detach(); }); } }
Upload File
Create Folder