Support the ongoing development of Laravel.io →
Authentication Input Forms
Last updated 2 years ago.
0

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

Last updated 7 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

moschel26 moschel26 Joined 21 Dec 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.