Looking to use eloquent with array chunk but hitting errors that the first parameter needs to be array.
This is how I am doing things:
public function index() {
$externalAccounts = ExternalUserAccount::all();
return View::make('user_creator.index', compact('externalAccounts'));
}
Then in my view:
@foreach (array_chunk($externalAccounts, 4) as $key => $externalAccount)
<div class="form-group">
{{ Form::label($externalAccount->name, $externalAccount->display_name) }}
{{ Form::checkbox($externalAccount->name, $externalAccount->id) }}
</div>
@endforeach
However, if I use to array in my controller:
$externalAccounts = ExternalUserAccount::all()->toArray();
Then I get 'trying to get property of non object etc' error.
How should I do this?