I have a table, from an old database, where the primary key is a string. When I print it on the screen, it is printed like an integer. Eg. if the key is 8-001abc, on the screen I have 8.
This is my code: model
protected $table = 'mytable';
public $primaryKey = 'mykey';
public $incrementing = false;
protected $casts = [
'mykey' => 'string'
];
controller
$item = MyModel::where('somefield', '=', 0)->get();
return view('mymodel.index', compact('item'));
view
@foreach($odl as $rowodl)
<p></p>
@endforeach
any idea? thank you!
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1VaN3Bm
via IFTTT
Aucun commentaire:
Enregistrer un commentaire