Monday, February 27, 2017

Laravel - Parse error: syntax error, unexpected '<', expecting ']'

And now i have a situation in which im trying to create a form that list the cars in a cars table and if clicked, sends into another form which is based on a DB query that returns the data of the choosen car, which is identified with the modelesc variable. This form sends the data to a "orders" table.

After getting help in this forum in solving problems with it, now i have another different problem: " Parse error: syntax error, unexpected '<', expecting ']' " in the orders.blade.php. But what '<' ?? i dont see any in the code... Can someone help me out with this? This is the code:

CarController

function catalog() {
    $cars = DB::table('cars')->get();
    return view('catalog', compact('cars'));
}

function orders($modelesc=null) {
    $cars = DB::table('cars')->where('Model', '=', '$modelesc');
    return view('orders', compact('cars'));
}

Catalog.blade.php

@foreach($cars as $car)
{!! Form::open(array('action' => 'CarController@orders', 'method' => 'GET')) !!}
{!! Form::hidden('$modelesc', $car->Model) !!}
{!! Form::submit($car->Model) !!}
{!! Form::close() !!}                                       

@endforeach

Orders.blade.php

{!! Form::open(array('action' => 'index', 'method' => 'POST')) !!}
{!! Form::text('Model', $car->Model) !!}
{!! Form::hidden(users_id, Auth::user()->id) !!}
{!! Form::hidden(Fabrication_date, date(Y-m-d)) !!}
{!! Form::select('Colour', [
    @foreach($colours as $colour)
        '$colour->Colour' => '$colour->Colour'
    @endforeach
]) !!}
{!! Form::hidden(Order_status_id, '1' !!}

{!! Form::close() !!}

This is the struture of the table 'orders'. The _id come from other tables, and i want to fill some values of the forms with this id´s. id, users_id, Model, Fabrication_date, Colour_id, Order_status_id




via Adato

Advertisement