%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/news/app/Models/
Upload File :
Create Path :
Current File : /var/www/html/news/app/Models/Category.php

<?php

namespace App\Models;

use Laracodes\Presenter\Traits\Presentable;

class Category extends BaseModel
{
    use Presentable;

    protected $presenter = CategoryPresenter::class;

    protected $fillable = [
        'name',
        'description',
        'parent_id'
    ];

    protected $hidden = [
        'password',
        'remember_token'
    ];

    protected $casts = [
        'id'          => 'integer',
        'name'        => 'string',
        'description' => 'string'
    ];
    protected $dates = [

    ];

    public function media()
    {
        return $this->morphOne(Media::class, 'mediable');
    }

    public function parent()
    {
        return $this->hasOne(Category::class, 'id', 'parent_id');
    }

    public function children()
    {
        return $this->hasMany(Category::class, 'parent_id');
    }

    public function articles()
    {
        return $this->hasMany(Article::class, 'category_id');
    }

}

Zerion Mini Shell 1.0