laravel-5.4

Laravel: how to force HTTPS?

丶灬走出姿态 提交于 2019-11-30 13:12:10
I'm starting to develop a new big app, and I'm using Laravel this time, and it's the first time. I need to force HTTPS for all pages, it's not important if from code or by .htaccess, but I'm not able to find a simple tutorial. The official docs dosn't speak about this problem. For info, my acutal .htaccess is <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews </IfModule> RewriteEngine On # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ /$1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d

Get authenticated user with Laravel Passport and grant password

久未见 提交于 2019-11-30 11:28:24
I did an API REST with Laravel and now I'm trying to consume it. The thing is I need to authenticate users in the API and I am using the Password Grant method. I can authenticate users correctly and I can get an access token but from then, I don't see a way to retrieve the authenticated user with the access token in my consuming application. I tried in the API with a route like this: Route::get('/user', function(Request $request) { $user = $request->user(); // Even with $user = Auth::user(); return $user; }); No dice. I am reading Passport code but I can't figure it out. My guess is that I

Lravel 5.4: JWT API with multi-auth on two tables one works the other not

北城余情 提交于 2019-11-30 10:47:21
I am using... Laravel 5.4 tymon/jwt-auth : 1.0.0-rc.2 I have application with two authentications API one is customers and the other is drivers each one has it's own table. now let me describe shortly JWT package installation and the updates I did on it. I installed the package as described in the JWT documents exactly. Now comes to the quick start here I updated two Models one is the User and the second Driver . Comes here to the Configure Auth guard again I used the configuration for the two guards let me show a snapshot of my auth.php . 'defaults' => [ 'guard' => 'api', 'passwords' =>

laravel 5.4 change authentication users table name

拟墨画扇 提交于 2019-11-30 07:32:19
I'm currently using the laarvel5.4 authentication in my application; and I want to change the users table name while keeping its role as it is in the authentication logic, all I need is just to change the name. It seems that Laravel changer the Auth file and code structure in the latest version, so auth.php doesn't really look as in the previous versions of laravel. I have done the following so far, but it's still not working gy giving me an error saying that the table users doesn't exist: 1- I have changed the migration 's up() and down() functions to create and drop staff table instead of

Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1

拟墨画扇 提交于 2019-11-30 04:46:22
Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 0 installs, 0 updates, 1 removal - Removing genealabs/laravel-caffeine (0.3.12) Writing lock file Generating optimized autoload files Illuminate\Foundation\ComposerScripts::postAutoloadDump @php artisan package:discover [Symfony\Component\Debug\Exception\FatalThrowableError] Class 'GeneaLabs\LaravelCaffeine\LaravelCaffeineServiceProvider' not found Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1 Abed Bilani Add this in

How to logout and redirect to login page using Laravel 5.4?

末鹿安然 提交于 2019-11-30 01:23:24
I am using Laravel 5.4 and trying to implement authentication system. I used php artisan command make:auth to setup it. I edited the views according to my layout. Now, when I am trying to logout it throwing me this error NotFoundHttpException in RouteCollection.php line 161: could any one help me how to logout? In your web.php (routes): add: Route::get('logout', '\App\Http\Controllers\Auth\LoginController@logout'); In your LoginController.php add: public function logout(Request $request) { Auth::logout(); return redirect('/login'); } Also, in the top of LoginController.php , after namespace

Laravel : Many to many insertion

て烟熏妆下的殇ゞ 提交于 2019-11-30 00:57:05
问题 I have two models, User and Team The relationship between them is ManyToMany : In User : public function teamMembers(){ return $this->belongsToMany('App\Team')->withPivot('id');; } And in Team : public function teamMembers(){ return $this->belongsToMany('App\User')->withPivot('id');; } Now i want to add users to a specific team. So the pivot table name is team_user . Now the data i want to insert to pivot table is : array:4 [▼ "_token" => "mlwoAgCQYals1N1s2lNa4U5OTgtMNHh9LUhNGrWh" "team_id" =

Laravel 5.4 create model, controller and migration in single artisan command

半城伤御伤魂 提交于 2019-11-29 18:40:43
I can create a model and resource controller (binded to model) with the following command php artisan make:controller TodoController --resource --model=Todo I want to also create a migration with the above command, is it possible? You can do it if you start from the model php artisan make:model Todo -mcr if you run php artisan make:model --help you can see all the available options -m, --migration Create a new migration file for the model. -c, --controller Create a new controller for the model. -r, --resource Indicates if the generated controller should be a resource controller Update As

Laravel: how to force HTTPS?

邮差的信 提交于 2019-11-29 17:58:12
问题 I'm starting to develop a new big app, and I'm using Laravel this time, and it's the first time. I need to force HTTPS for all pages, it's not important if from code or by .htaccess, but I'm not able to find a simple tutorial. The official docs dosn't speak about this problem. For info, my acutal .htaccess is <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews </IfModule> RewriteEngine On # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d

Get authenticated user with Laravel Passport and grant password

被刻印的时光 ゝ 提交于 2019-11-29 17:03:52
问题 I did an API REST with Laravel and now I'm trying to consume it. The thing is I need to authenticate users in the API and I am using the Password Grant method. I can authenticate users correctly and I can get an access token but from then, I don't see a way to retrieve the authenticated user with the access token in my consuming application. I tried in the API with a route like this: Route::get('/user', function(Request $request) { $user = $request->user(); // Even with $user = Auth::user();