Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel find or fail exception

use IlluminateDatabaseEloquentModelNotFoundException;

// Will return a ModelNotFoundException if no user with that id
try
{
    $user = User::findOrFail($id);
}
// catch(Exception $e) catch any exception
catch(ModelNotFoundException $e)
{
    dd(get_class_methods($e)); // lists all available methods for exception object
    dd($e);
}
Comment

PREVIOUS NEXT
Code Example
Php :: php get client ip address 
Php :: laravel make:listner 
Php :: laravel time format 
Php :: wp php related post by category 
Php :: php mysql insert data 
Php :: convert base64 string to pdf in php 
Php :: twig jsoncencode 
Php :: faker image laravel 
Php :: php mysql connect 
Php :: laravel print request data 
Php :: php get user ip address 
Php :: total no of occurances in string php 
Php :: Get PHP Date Time Difference in Days, Hours, Minutes, and Seconds 
Php :: laravel collection shuffle 
Php :: echo query in laravel 
Php :: General error: 1215 Cannot add foreign key constraint laravel 
Php :: cakephp 404 exception 
Php :: laravel db transaction 
Php :: php get myme type of image 
Php :: php milliseconds 
Php :: create a exporter in laravel command 
Php :: eloquent using last() 
Php :: center mode slick slider 
Php :: js check if div is empty 
Php :: wordpress escape for html 
Php :: string remove line breaks php 
Php :: laravel pluralization text 
Php :: remove autoupdate wordpress 
Php :: check if input file is set codeigniter 
Php :: combine array except common ones php 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =