lundi 20 mai 2019

Category dropdown is fetching more then the title in laravel 5 is not working

My category dropdown is fetching more then

{"id":1,"title":"Arts Blog","slug":"arts-blog","created_at":null,"updated_at":null}

I just want the "title" as $category->title...

Here's PostsController.php

public function edit(Post $post)
{
    $posts = Post::with('author');

    $categories = Category::all();
    $cats = array();
        foreach ($categories as $category){
            $cats[$category->id] = $category->title;
            }

    return view('posts.edit')->withPost($post)->withCategories($cats);
}

edit.blade.php

<div class'form-group'>


</div>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire