Mohit
0
Q:

Looping Through Select Option Dropdown with Laravel Collective

//Controller
public function create()
{
  
        $departments = Departments::all();
        $select = [];
        foreach($departments as $department){
            $select[$department->id] = $department->title;
        }
        return view('employees.create', compact('select'));
}

//View
{!!Form::open(['method'=>'Post', 'action'=>'EmployeeController@store','files'=>true])!!}
@csrf
  <div class="form-group col-md-12">
	  {!! Form::label('Job Status')!!}
  </div>
  <div class="form-group col-md-6">
     {!! Form::label('Role')!!}
     {!!Form::select('role_id', ['1' => 'Employee'], 'User', ['class' => 'form-control' ]) !!}
  </div>

  <div class="form-group col-md-6">
	 {!! Form::label('Position')!!}
	 {!!Form::select('job_id', ['1' => 'Developer', '2' => 'Full Stack Developer', '4' =>
                    'Intern'],['class' => 'form-control' ]) !!}
  </div>
  <div class="form-group col-md-6">
     {!! Form::label('Choose a Department')!!}
	 {!! Form::select('department_id', $select, null, ['class'=>'form-control']) !!}
  </div>
  <div class="login100-form-btn">
     {!!Form::submit('Submit', ['class'=>'btn'])!!}
	 {!!Form::close() !!}
  </div>
0

New to Communities?

Join the community