FindOrFail laravel 5 function for specific feed

This is my code:

$get_all = Geo_Postal_us::findOrFail($postal);

Using this query, laraveltry to find the identifier specified in the table.

I do not have an identifier, for the primary key I have a mail column.

So, how to set the function to search the value in the mail column, and not to search from the id column?

Thank,

+4
source share
1 answer

You can create the behavior you are looking for with the following:

Geo_Postal_us::where('postal', $postal)->firstOrFail();
+20
source

All Articles