JackSlayer94 JackSlayer94 - 1 month ago 6x
MySQL Question

Populate data from MySQL on Laravel Page

I have a bootstrap drop down on a Laravel page(Sign Up page) and would like to populate it using data from my MySQL database. So in my routes, I have something like this:

Route::get('/signup', [
'uses' => 'SigninSignupController@getSignup',
'as' => 'signup'

And in my SigninSignupController:

public function getSignup(){
$users = DB::table('users')->get();
return view('pages.signup', ['users' => $users]);

In my signup.blade.php:

@foreach ($users as $user)
<option> {{ $user->orgid; }} </option>

But I get an error like this : http://pastebin.com/543VGaq9

In my SigninSignupController, I have these:

use Illuminate\Support\Facades\DB;
namespace App\Http\Controllers;

What am I doing wrong? Can someone point it out?


Change namespace and use to:

namespace App\Http\Controllers;

use DB;

Also, you don't need to use ; in Blade templates, so it should look like:

{{ $user->orgid }}