I am new to Laravel. Please excuse the newbie question but how do I find if a record exists?
<?php
$user = User::where('email', '=', Input::get('email'));
What can I do here to see if $user
has a record?
I am new to Laravel. Please excuse the newbie question but how do I find if a record exists?
<?php
$user = User::where('email', '=', Input::get('email'));
What can I do here to see if $user
has a record?
Shortest working options:
It depends if you want to work with the user afterwards or only check if one exists.
If you want to use the user object if it exists:
And if you only want to check
Or even nicer
Laravel 5.6.26v
to find the existing record through primary key ( email or id )
then
include " use DB " and table name user become plural using the above query like user to users
It's simple to get to know if there are any records or not
you can use laravel validation .
But this code is also good:
This will check if particular email address exist in the table: