jeudi 2 mai 2019

get() doesn't work, but First() does. I need to use get() to get all my data

I have a page that shows categories/main posts which when clicked will navigate to a page with sub-posts concerning the topic of the main post. The problem is, however, that when I try to use ->get() It shows the following error: Oops an Error occured

The function I use to get the information is the following (URL Shows as slug):

public function knowledge_collection($slug, Request $request){
    $knowledge_post_primary = Knowledge::where('knowledge_slug', $slug)->get();
    //dd($knowledge_post_primary);
    $knowledge_posts = Knowledge_Post::where('parent_id', $knowledge_post_primary->id)->get();
    return view('knowledge.knowledge_posts', compact('knowledge_posts', 'knowledge_post_primary'));
}

It's most likely an easy fix, but I can't seem to find it. I hope someone else can and will be able to help me :)

I've tried requesting the data in different ways and with a FindorFail(), but nothing worked up till now.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire