class CarsMake extends Model
{
protected $fillable = [
'title',
'body',
'published_at'
];
protected $dates = ['published_at'];
public function setPublishedAtAttribute($date)
{
$this->attributes['published_at'] = Carbon::createFromFormat('Y-m-d', $date);
}
public function scopePublished($query)
{
$query->where('published_at', '<=', Carbon::now());
}
public function scopeUnPublished($query)
{
$query->where('published_at', '>', Carbon::now());
}
public function user()
{
return $this->belongsTo('App\User');
}
}