Products Table:
Primary Key-> product_code
Movements table:
Primary Key-> movement_code / Foreign Key-> product_code
These would be the two tables to relate, and I use theLaravel collective
I'm supposed to stay like this:
InMovimientosController
$productos = Producto::lists('nombre','codigo_producto'); /Este a veces me da error por que no se exactamente como ponerlo si en una funcion publica o como.
Increate.blade
{!! Form::label('codigo_producto', 'Código del Producto') !!}
{!! Form::text('codigo_producto', $productos, null, ['class' => 'form-control', 'placeholder' => 'Código del producto', 'required']) !!}
Inedit.blade
{!! Form::label('codigo_producto', 'Código del Producto') !!}
{{ Form::model($productos, array('route' => array('admin.productos.index', $productos->codigo_producto))) }}
But the case is that the field disappears from the form directly or appears, I leave it as it was and of course it works, but it does not show the foreign keys.
The method
lists
no longer works, you have to usepluck
.https://laravel.com/docs/5.4/queries#retrieving-results
Retrieving A List Of Column Values
If you would like to retrieve a Collection containing the values of a single column, you may use the pluck method. In this example, we'll retrieve a Collection of role titles:
You may also specify a custom key column for the returned Collection: