<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class BlogPost extends Model {
protected $fillable = ['slug','author','category','tags','featured_image','title','excerpt','content','meta_title','meta_description','og_image','status','published_at'];
protected $casts = ['tags' => 'array', 'published_at' => 'datetime'];
public function scopePublished($q) { return $q->where('status','published')->where('published_at','<=',now())->orderByDesc('published_at'); }
public function getRouteKeyName() { return 'slug'; }
}