0

私は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>

しかし、そうしようとすると、最後から 2 番目の行に次のエラーが表示されます ( ), 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'));
    }
}
4

2 に答える 2

1

そのようにブレードを使用することはできません。

しかし、あなたは同じ結果を得ることができます

{!! Form::select('location', $locations->lists('id','location_area'), null, ['class' => 'form-control']); !!}
于 2015-04-01T09:01:18.417 に答える