if exists laravel code example
Example 1: check if file exists laravel
$file = public_path('storage/images/' . $value)
if(! file_exists($file)){
return asset('storage/images/default.png');
}
Example 2: laravel check record exists
$user = User::where('email', '=', Input::get('email'))->first();
if ($user === null) {
}
Example 3: laravel exists validation
'state_id' => 'exists:states,id'
Example 4: if notexists in laravel query
if (User::where('email', '=', Input::get('email'))->exists()) {
}
Example 5: check for an existing user laravel eloquent
$users = User::where('email', '=', $request->input('email'))->first();
if ($users === null) {
} else {
}