lundi 12 octobre 2015

Laravel 5.1: getting a record with no primary key using Eloquent

On Laravel 5.1's documentation, it shows how to use Eloquent to retrieve one record from a model:

$flight = App\Flight::find(1);

It seems that it assumes the corresponding table has a primary key. Is it possible to retrieve a record in this particular fashion from a table that does not have a primary key? I do know I can use DB:table('xyz') to get this data.

So, I have a table like this

   column1  |  column2
-----------------------
some data 1 | some data 2  <-- row 1

and I want to retrieve row 1.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire