Want to load country list from database table in blade

Posted 2 years ago by kpisor

Hi, I've got a blade view that is loading happily with my user and associated data (the user's country, etc.). However, I'd like to load the complete list of countries from my country table in the database. When I set up this sort of thing in normal PHP, I just create two database resources, and then I write from them separately as I need in the output file.

In Laravel, I'm starting with my UserController, which has:

public function edit(User $user)
        $user->load('country', 'prefecture');
        return view('users.edit', compact('user'));

So this is like having a single db resource loaded when I load my view. All is fine here. But I'd like another db resource that loads all my countries, so that a element will load the entire country list.

How is this best accomplished in the blade (or not--in the controller instead?). Please help!

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.