moschel26 said:
I want to create a dropdown list where the data retrieved from the database, ie dropdown level. the value of the dropdown level is taken from the table level.
use pluck()
// code in controller
use App\Level;
public function someFunction()
{
$data['levels'] = Level::get()->pluck('name', 'id');
return view('some_view', $data);
}
// view
<select>
@foreach ($levels as $level)
<option value="{{ $level->id }}">{{ $level->name }}</option>
@endforeach
</select>
hope that's what you're looking for
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community