How to organize views in Laravel breeze?

Viewed 31

This may be a dumb question, but I've started exploring Laravel Breeze with vue and I'm not sure how to manage resources and their views. (Using Laravel 9)

For example, if I have a table 'members' and a resource controller 'MemberController', ordinarily in the web.php file I would do something like:

Route::resource('members', MemberController::class)->names('members');

Then I'd create a 'member' folder in my resource/views folder to store the views for that table. I could then call the view from the MemberController something like:

public function index()
{
  $members = Member::all();
  return view('member.index', compact('members'));
}

I'm trying to do something similar using vue in breeze, so I guess I'd have the vue pages in the 'resources/js/Pages' folder. But this didn't seem to work properly.

I don't know how to transition from the previous approach of handling resources and views to Breeze using vue.

What's the recommended way to handle resources in an SPA with Breeze/vue?

1 Answers

After following Djave's suggestion, I took a look at the sample app from inertia.js and that answered everything.

The problem I had was due to using the dot notation when specifying the path to the vue page. So, in my example above, it should instead be like this:

return view('Member/Index', compact('members'));

The inertia sample app code has a lot of good examples!

Related