I'm getting an error in my controller Undefined property: Illuminate\Database\Eloquent\Collection::$created_at
How can I access a column created_at
from a result of laravel query?
Controller Code:
public function getDashboard() {
$posts=Post::latest('created_at')->get();
dd($posts->created_at);
// $posts->created_at=Carbon::parse($posts->created_at)->diffForHumans(Carbon::now());
return view('dashboard',compact('posts'));
}
It works with findOrFail(some_id)
but not with this, why?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire