laravel Archives - 7-Views
How To Debug Queries In Laravel
We can do this by #1 Simple Query Debugging $results = User::where(function($q) use ($request) { $q->orWhere(‘name’, ‘like’, ‘%7-Views%’); $q->orWhere(’email’, ‘=’, ‘info@7-views.com’); })->toSql(); The above method does not include query bindings. #2 Listening For Query Events \DB::listen(function($sql, $bindings, $time) { dump($sql); dump($bindings); dump($time); }); This method returns queries with timings and bindings.
storage/oauth-private.key does not exist or is not readable
This issue arises when we run API in Laravel app using Passport but the passport package is not installed. The solution is: Go to Command Prompt and go to the project directory and run the following command. php artisan passport:install
How to get the current user in a __construct method of controller
This issue arises because the controller __construct method executes before any middleware. so it returns null when we call auth()->user() So the solution of the issue is, inside your Controller __construct method call this. public function __construct() { $this->middleware(function ($request, $next) { dump(auth()->user()); return $next($request); }); }