laravel check record exists
$user = User::where('email', '=', Input::get('email'))->first();
if ($user === null) {
// user doesn't exist
}
laravel check record exists
$user = User::where('email', '=', Input::get('email'))->first();
if ($user === null) {
// user doesn't exist
}
check for an existing user laravel eloquent
$users = User::where('email', '=', $request->input('email'))->first();
if ($users === null) {
// User does not exist
} else {
// User exits
}
create if not exist laravel
if(!Numbers::where('country',$country)->exists()){
Numbers::Create([
'country' => $country
]);
}
create if not exist laravel
Occasionally, you may need to update an existing model or create a new model if
no matching model exists. Like the firstOrCreate method, the updateOrCreate
method persists the model, so there is no need to manually call the save method.
In the example below, if a flight exists with a departure location of Oakland
and a destination location of San Diego, its price and discounted columns will
be updated. If no such flight exists, a new flight will be created which has
the attributes resulting from merging the first argument array with the
second argument array:
$flight = Flight::updateOrCreate(
['departure' => 'Oakland', 'destination' => 'San Diego'],
['price' => 99, 'discounted' => 1]
);
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us