0

I have a drop down, and on this drop down I want to fill it with the data I have on the other database table.

P.S - My dropdown and its other form inputs have its own database table namely tbl_movies , and on the dropdown itself which I want to fill in the data o the database table namely tbl_clients .

Should I make a relationship or what not? Idk sorry help and guide me pls

I have this dropdown form and how should I fill it with data on the other table ?

 {{Form::select('client', null,
                    ['class' => 'form-control', 'placeholder' => 'Select Status...'])}}

1 Answer 1

1

Get your data from table and Pass data from your controller to view

$data['movies'] = Movies::pluck('name','id');
return view('viewPageName',$data); // pass your data to view page from controller

On your view file instead of your select use this

{{Form::select('client', $movies,
                ['class' => 'form-control', 'placeholder' => 'Select Status...'])}}

Hope this idea will help you!

Sign up to request clarification or add additional context in comments.

16 Comments

wait $data['movies'] = Movies::pluck('name','id'); how can I pass it to view ? where and how? anywhere? should i use @php @endphp or what?
where should I put it to controller? store or what?
yeah sir, but which public function should I code? is it okay on the public function index?
why is it $movies instead of $data ?
I will post another question sir will you answer it?
|