<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
      
    public function admin(){
        return $this->belongsTo('App\Admin');
    }

   public function categories()
    {
        return $this->belongsToMany(CategoriePost::class,'post_pivot_categories','post_id','categorie_post_id');
    }

    public function tags()
    {
        return $this->belongsToMany(Tag::class,'post_pivot_tags','post_id','tag_id');
    }
    public function scopeApproved($query)
    {
        return $query->where('is_approved', 1);
    }
    public function scopePublished($query)
    {
        return $query->where('status', 1);
    }
    


}
