KUJUNTI.ID MINISH3LL
Path : /var/www/html/phkaynews-v2/app/Models/
(S)h3ll Cr3at0r :
F!le Upl0ad :

B-Con CMD Config cPanel C-Rdp D-Log Info Jump Mass Ransom Symlink vHost Zone-H

Current File : /var/www/html/phkaynews-v2/app/Models/Category.php


<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Models\Post;

class Category extends Model
{
    use HasFactory;
    use SoftDeletes;
    protected $table = 'categories';
    protected $fillable = [
        'name', 'feature', 'order', 'slug'
    ];
    protected $primaryKey = 'id';
    public function posts()
    {
        return $this->belongsToMany(Post::class, 'post_categories')->withTimestamps();
    }
    public function post_categories()
    {
        return $this->hasMany('App\Models\PostCategory', 'category_id');
    }

    public function getPostCatAttribute()
    {
        if ($this->post_categories()->count() > 0) {
            return true;
        }
        return false;
    }
}

© KUJUNTI.ID