RSS

Category Archives: Laravel

Video

Laravel 5 Audits and Logs

 
Leave a comment

Posted by on November 18, 2017 in Laravel, PHP

 

Tags:

Video

Laravel 5.5 Jwt Authentication

 
Leave a comment

Posted by on November 14, 2017 in Laravel, PHP

 

Tags: ,

Laravel Load Custom Error Views

This piece of code shows how to load different error views for each exceptions occurred, The display can be controlled depending on the context.

public function render($request, Exception $e)
{
if ($e instanceof HttpException) {
$statusCode = $e->getStatusCode();

if (view()->exists('errors.'.$statusCode)) {
return response(view('errors.'.$statusCode, [
'msg' => $e->getMessage(),
'code' => $statusCode
]), $statusCode);
}
}

return parent::render($request, $e);
}
 
Leave a comment

Posted by on October 25, 2017 in Laravel, PHP

 

Tags:

How to enable CORS in Laravel 5

How to enable CORS in Laravel 5

1. Add middleware
php artisan make:middleware Cors

return $next($request)
->header(‘Access-Control-Allow-Origin’, ‘*’)
->header(‘Access-Control-Allow-Methods’, ‘GET, POST, PUT, DELETE, OPTIONS’);

2. Register middleware as a route middleware

3. Use middleware in routes which support CORS

 
1 Comment

Posted by on April 20, 2017 in Laravel

 

Tags: ,