我是 Laravel 和 Blade 的新手,一直在尝试使用Illuminate/Html
.
我有一张桌子叫service_locations(location_id, location_area)
.
使用上表我试图填充下面的下拉列表:
<div class="form-group">
{!! Form::label('location', 'Location:') !!}
{!! Form::select('location', array(
@foreach($locations as $local)
'{{ $local->location_id }}' => '{{ $local->location_area }}',
@endforeach
), null, ['class' => 'form-control']) !!}
</div>
但是当我尝试这样做时,我在倒数第二行 ( ), null, ['class' => 'form-control']) !!}
) 中收到以下错误:
syntax error, unexpected '<', expecting ')'
我无法弄清楚上述代码的问题。
编辑 1 这是我的控制器的样子:
<?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'));
}
}