Muhammad Kazim
Muhammad Kazim

Reputation: 621

Laravel how to use code inside collective dropdown

I have an array and i use foreach, below is code

@foreach($param2 as $par)
{{$par->account}}
@endforeach

now i want to use the $par->account in drop down

i am using below code

    {!! Form::select('[
'option' => $par->account
], null, ['placeholder' => '<select>','class'=>'form-control']) !!}

there are 3 items in array, but it shows only single item.

Upvotes: 0

Views: 362

Answers (1)

Misagh Laghaei
Misagh Laghaei

Reputation: 1369

Generate array and send it from controller :

Controller :

foreach($param2 as $par) {
    $accounts[] = $par->account;
}

In view :

{!! Form::select('name', $accounts, null, ['placeholder' => '<select>','class'=>'form-control']) !!}

Upvotes: 1

Related Questions