I am building an RESTful API in Laravel 5.2. In my resource controllers I want to use implicit model binding to show resources. e.g. When a request is made for a resource that doesn’t exist Laravel automatically returns the NotFoundHttpException NotFoundHttpException I want to return my own custom respo…
Tag: laravel
Session sweeping lottery
Can someone explain what a session sweeping lottery is? I’ve attached the default session config file for the Laravel framework. Questions: 1. It says that some session drivers must manually sweep their storage location. Could someone describe this process and why it is necessary? What session drivers r…
How to get all pending jobs in laravel queue on redis?
The queue:listen was not run on a server, so some jobs were pushed (using Redis driver) but never run. How could I count (or get all) these jobs? I did not find any artisan command to get this information. Answer If someone is still looking for an answer, here is the way I did it: $connection is the RedisR…
disable web middleware for specific routes in laravel 5.2
I want to guest users have access to home page but in built in authentication process laravel redirects to login page. how can i give guest users access to home page? my routes.php: and authenticate.php and this is my kernel.php Answer Remove the middleware from HomeController construct:
Return values only (no keys/associative array) in Laravel
Situation I have the following code to get all data as an array: This will return the data in the following format: But I want only the values as a regular array (no keys/associative array) so the array is not converted to an object when I convert it to JSON: Inadequate solutions I know I can convert this wit…
Laravel: How to access session value in AppServiceProvider?
Is there any way available to access Session values in AppServiceProvider? I would like to share session value globally in all views. Answer You can’t read session directly from a service provider: in Laravel the session is handled by StartSession middleware that executes after all the service providers…
Laravel: find if a pivot table record exists
I have two models which are joined by a pivot table, User and Task. I have a user_id and a task_id. What is the neatest way to check whether a record exists for this combination of user and task? Answer You have a couple options depending on your situation. If you already have a User instance and you want to
Laravel: Error InvalidArgumentException
I’ upload the project from localhost to my dedicated server and after so many problems, finally some pages works domain.com | domain.com/home | domain.com/allsites etc.. But now, the routes “domain.com/site/create” “domain.com/site/ID/manage”, “domain.com/site/ID/edit”…
Laravel error: Missing required parameters for route
I keep getting this error ErrorException in UrlGenerationException.php line 17: When ever any page loads and I’m logged in. Here is what my nav looks like @if(Auth::guest()) <…
mysql server has gone away error during installing migration (laravel)
So I am using my cmd on my laravel folder and I tried to do (php artisan migrate:install). 2 errors came up. [PDOException] SQLSTATE[HY000] [2006] MySQL server has gone away [ErrorException] PDO:…