I have the following:
\App\Models\Finance\FinanceAccount::lists('name', 'id')
At the top of one of my views but it keeps giving me the error:
htmlentities() expects parameter 1 to be string, array given (View: mysite\views\modals\add.blade.php)
What am I doing wrong?
That makes sense about it being an array, I put it into a select and it's working now:
<div class="form-group">
{!!Form::label('Account')!!}
{!!Form::select('account', \App\Models\Finance\FinanceAccount::getSelectOptions(), 1, ['class' => 'form-control'])!!}
</div>
Is there a way to set the namespace for views, so I don't have to type the full namespace all the time?
lists
gives an array and that's not something you can echo out with{{ }}
. What you need to do is to loop orimplode
the array if you want to print it's content.With
foreach
With
implode
With
Form::select
If you don't want to use your namespace (which you never should) in your view, send the data from your controller to your view file.
If you have this in your controller
The
$baz
variable is then available in your view file. So you can do this: