Search
 
SCRIPT & CODE EXAMPLE
 

PHP

return error when duplicated laravel

try {
    $user->save();
    return redirect()->back()->with('status', 'Saved!');

} catch(IlluminateDatabaseQueryException $e){
    $errorCode = $e->errorInfo[1];
    if($errorCode == '1062'){
       return back()->with('error', 'Duplicated data');
    }
    else{
     return back()->with('error', $e->getMessage());
    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: how add confirmation box in php before deleting 
Php :: php redirect if not logged in 
Php :: regex to check date format php 
Php :: php int min 
Php :: logout in laravel 8 
Php :: setcookie php 
Php :: get site url with protocol in php 
Php :: Script timeout passed, if you want to finish import 
Php :: laravel get all vendor files 
Php :: php get string before character 
Php :: Check duplicate email in laravel using jQuery 
Php :: Command "route:scan" is not defined. 
Php :: Making visible or hidden attributes from Eloquent temporarily 
Php :: nova resource title function 
Php :: Laravel factory avatars 
Php :: wp_mail html content 
Php :: laravel print exception message 
Php :: php format datetime 
Php :: laravel eloquent order by alphabetical order 
Php :: Changer le logo Admin WordPress 
Php :: php curl ssl verify 
Php :: php header redirect same page 
Php :: laravel faker car plate br mercossul 
Php :: Search for text in string php 
Php :: laravel collection get price sum 
Php :: php get end date of month 
Php :: loop through values of hash php 
Php :: file get content using call api in php 
Php :: set null on foreign key deletion in laravel 
Php :: how to get the last inserted id in laravel 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =