How to make a Trait in Laravel

Well, laravel follows PSR-4 so you should place your traits in: app/Traits You then need to make sure you namespace your trait with that path, so place: namespace App\Traits; At the top of your trait Then make sure when you save the file, the file name matches the trait name. So, if your trait is … Read more

How to set laravel 5.3 logout redirect path?

This is how I did it. In Auth\LoginController you have: use AuthenticatesUsers; Change it to: use AuthenticatesUsers { logout as performLogout; } Then, define a new logout() method in your LoginController: public function logout(Request $request) { $this->performLogout($request); return redirect()->route(‘your_route’); } Sure, regular logout() method in that trait has only 3 lines (used to log users … Read more

Laravel Passport Key path oauth-public.key does not exist or is not readable

You do not mention your installation steps. Presume you did the following: composer require laravel/passport Register the service provider inside config/app.php Laravel\Passport\PassportServiceProvider::class, Run the migrations php artisan migrate Lastly generate the keys using php artisan passport:install I see you are trying it on Windows. I saw an OpenSSL problem on Windows, might help you.

Adding Access-Control-Allow-Origin header response in Laravel 5.3 Passport

The simple answer is to set the Access-Control-Allow-Origin header to localhost or *. Here’s how I usually do it: Create a simple middleware called Cors: php artisan make:middleware Cors Add the following code to app/Http/Middleware/Cors.php: public function handle($request, Closure $next) { return $next($request) ->header(‘Access-Control-Allow-Origin’, ‘*’) ->header(‘Access-Control-Allow-Methods’, ‘GET, POST, PUT, DELETE, OPTIONS’); } You can replace … Read more

How to use API Routes in Laravel 5.3

You call it by http://localhost:8080/api/test ^^^ If you look in app/Providers/RouteServiceProvider.php you’d see that by default it sets the api prefix for API routes, which you can change of course if you want to. protected function mapApiRoutes() { Route::group([ ‘middleware’ => ‘api’, ‘namespace’ => $this->namespace, ‘prefix’ => ‘api’, ], function ($router) { require base_path(‘routes/api.php’); }); … Read more

What is the best practice for adding constants in laravel? (Long List)

For most constants used globally across the application, storing them in config files is sufficient. It is also pretty simple Create a new file in the config directory. Let’s call it constants.php In there you have to return an array of config values. return [ ‘options’ => [ ‘option_attachment’ => ’13’, ‘option_email’ => ’14’, ‘option_monetery’ … Read more

laravel 5.3 new Auth::routes()

Auth::routes() is just a helper class that helps you generate all the routes required for user authentication. You can browse the code here https://github.com/laravel/framework/blob/5.3/src/Illuminate/Routing/Router.php instead. Here are the routes // Authentication Routes… $this->get(‘login’, ‘Auth\LoginController@showLoginForm’)->name(‘login’); $this->post(‘login’, ‘Auth\LoginController@login’); $this->post(‘logout’, ‘Auth\LoginController@logout’)->name(‘logout’); // Registration Routes… $this->get(‘register’, ‘Auth\RegisterController@showRegistrationForm’)->name(‘register’); $this->post(‘register’, ‘Auth\RegisterController@register’); // Password Reset Routes… $this->get(‘password/reset’, ‘Auth\ForgotPasswordController@showLinkRequestForm’); $this->post(‘password/email’, ‘Auth\ForgotPasswordController@sendResetLinkEmail’); $this->get(‘password/reset/{token}’, ‘Auth\ResetPasswordController@showResetForm’); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)