php - Unable to dynamically load dropdown list using Blade -
i'm new laravel , blade , have been trying create view using illuminate/html
.
i have table called service_locations(location_id, location_area)
.
using above table i'm trying populate below dropdown list:
<div class="form-group"> {!! form::label('location', 'location:') !!} {!! form::select('location', array( @foreach($locations $local) '{{ $local->location_id }}' => '{{ $local->location_area }}', @endforeach ), null, ['class' => 'form-control']) !!} </div>
but attempt so, getting following error in second-last line (), null, ['class' => 'form-control']) !!}
):
syntax error, unexpected '<', expecting ')'
i not able figure out issue above code.
edit 1 here's controller looks like:
<?php namespace app\http\controllers; use app\service_location; use app\service_type; use app\http\requests; use app\http\controllers\controller; use illuminate\http\request; class pagescontroller extends controller { public function index() { $locations = service_location::all(); $services = service_type::all(); return view('home.index', compact('locations','services')); } }
you cant use blade way,
but can achieve same result
{!! form::select('location', $locations->lists('id','location_area'), null, ['class' => 'form-control']); !!}
Comments
Post a Comment