Laravel Archives - 7-Views
How to Configure SMTP using MailHog in Laravel using Homestead
MailHog is enabled by defualt in HomeStead. In your .env file replace the Mail Settings. MAIL_DRIVER=smtp MAIL_HOST=127.0.0.1 MAIL_PORT=1025 MAIL_USERNAME=testuser MAIL_PASSWORD=testpwd MAIL_ENCRYPTION=null Clear you cache by using php artisan optimize:clear and just open follwing url in your tab. http://192.168.10.10:8025 and its done!!!
Check For Foreign Key Constraint Violation In Laravel
DB::statement(‘SET FOREIGN_KEY_CHECKS=0;’); //Check Disable //DO YOUR OPERATION HERE DB::statement(‘SET FOREIGN_KEY_CHECKS=1;’); //Check enable
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); }); }