2
I’m trying to create a select with the following code:
My controller is like this:
public function create(){
$marcas = Marca::lists('descricao', 'id')->toArray();
return view('sistema.modelos.create', ['marcas'=>$marcas]);
}
My view is like this:
{!! Form::open(['route'=>'sistema.modelos.store']) !!}
{!! Form::select('marca_id', $marcas ) !!}
{!! Form::close() !!}
You’re making the following mistake:
Trying to get property of non-objec
Has anyone ever been through it? You know how to do it?
editing---
I already did that:
$marcas = Marca::all(['id', 'descricao']);
return view('sistema.modelos.create', compact('marcas',$marcas));
according to the link: https://stackoverflow.com/questions/29508297/laravel-5-how-to-populate-select-box-from-database-with-id-value-and-name-value
In this case select is even rendered, but stays like this:
<select name="marca_id"><option value="0">{id : 1 , descricao : NOME}</option></select>
This Pact has nothing to do. You don’t need to pass the variable in it.
– Wallace Maxters