Controller:
$groups = DB::table('groups')->lists('group_name');
Then Controller->Blade:
return view('dashboard')->with('groups', $groups);
And the Blade:
@if(!empty($groups))
{!! Form::open(array('url' => '/dashboard/send_group_msg', 'method' => 'post')) !!}
{!! Form::select('id', $groups, null, ['class' => 'form-control']) !!}
{!! Form:close() !!}
@endif
But this returns me this error (I tryed every possible way):
FatalErrorException in *** line 14:
syntax error, unexpected ':', expecting ',' or ';'
Line 14 is my last line from document. As you can see this is basic populating a select form in L5 but doesn't work. I tryed every possible way to do it and I was close only when I put it in array like this:
$items = array();
foreach ($groups as $group)
{
$items[$group->id] = $group->group_name;
}
But then this returns me this error:
Trying to get property of non-object
Please suggest me a proper solution.