Reputation: 85
I hope I can get assistance from here. A very amateur to Laravel.
Here is my code. I am trying to create a drop down select menu and the data should be from the database from another table which is actually connected using a foreign key only.
<div class="form-group">
{{ Form::select('size', array('a' => '', 'b' => ''), null,array('class'=>'form-control','style'=>'','placeholder' => 'Select Activity Category:','required' )) }}</div>
public function createPackage()
{
$package = chap_activity_package::all();
return view ('Chap_activity_packages.chap_activity_package', compact('chap_activity_packages'));
}
Upvotes: 2
Views: 401
Reputation: 163748
You should use pluck()
method which will generate list of properties for you, like:
$data = chap_activity_package::pluck('name', 'id');
Then use this data in Form::select
:
{!! Form::select('size', $data, null, array('class'=>'form-control', 'style' => '', 'placeholder' => 'Select Activity Category:', 'required' )) !!}
Upvotes: 2