There is no difference with Laravel 4 for this point, I think best practice is to elaborate all data in controller.
Jun 25, 2015
5
Level 1
Best practice for calling eloquent data inside view
Hi,
I recently upgraded to Laravel 5 from Laravel 4.
I've got three tables in my multilanguage app.
ORDER(id,shipping_id,language_id)
SHIPPING(id,number)
SHIPPING_LANGUAGE_DATA(id,shipping_id,language_id, number)
In laravel 4, i did this from inside the view (i know, extremely hackish)
<select id="shipping_id" name="shipping_id">
@foreach(Shipping::all() as $shipping)
<option value="{{$shipping->id}}" @if ($shipping->id == $order->shipping_id) selected = "selected" @endif>
{{$shipping->lang()->where('languages_id','=',$order->language)->first()->name}}
</option>
@endforeach
</select>
What is the best practice for me to do this in Laravel5? Should i create a two-level array of the Shippingmethods (in the Controller) and foreach them in the view?
Please or to participate in this conversation.