jeudi 2 juin 2016

Difference among return view(), return response()->view() and abort() in laravel

Suppose i want to return 404 error view from my controller's method and i have this block of code.

try {

        file_get_contents('http://ift.tt/1jv3Zxg');

    } 
catch (\Exception $e) {

        return view('errors.404'); // View::make('errors.404');

        // or                       

        return response()->view('errors.404'); // Response::view('errors.404');

        // or

        abort(404); // App::abort(404);

    }

Each time i'll see the same view output of 404. Here is my questions.

What is the difference among view(), response()->view() and abort()?

What is the particular use cases of them?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire