I have read laravel's auth LOGIN middleware. Currently, the user table corresponding to auth has been used. Now I need to create a persistence table Operator; this is the login table model of a front-end operator {code ...} to access this page, OperatorAuth must be verified in the middle... read laravel's auth LOGIN middleware;
Currently, the user table corresponding to auth is used;
Now you need to create a keep tableOperator
This is the login table model of a front-end operator.
Route::get('operator/index_1.html', ['middleware' => 'OperatorAuth', OperatorController@indexOne);Route::get('operator/index_2.html', ['middleware' => 'OperatorAuth', OperatorController@indexTwo);
To access this page, perform OperatorAuth intermediate verification.
There are two operators who access the preceding two routes
OperatorAuth
How do I write this middleware? Do I need to continue laravel auth?
Also, let's look at the process;
Visitor accessoperator/index_1.html
MiddlewareOperatorAuth
Log On. return after Successful Logonoperator/index_1.html
Visitor accessoperator/index_2.html
MiddlewareOperatorAuth
Log On. return after Successful Logonoperator/index_2.html
After the middleware verification is successful, the access address is returned. How can this be written in the middleware?
Is there any elegant code written by laravel? I saw a lot of code written by laravel very beautiful. The code I wrote is ugly.
Please give me some guidance. I have a low IQ.
Reply content:
Read laravel's auth LOGIN middleware;
Currently, the user table corresponding to auth is used;
Now you need to create a keep tableOperator
This is the login table model of a front-end operator.
Route::get('operator/index_1.html', ['middleware' => 'OperatorAuth', OperatorController@indexOne);Route::get('operator/index_2.html', ['middleware' => 'OperatorAuth', OperatorController@indexTwo);
To access this page, perform OperatorAuth intermediate verification.
There are two operators who access the preceding two routes
OperatorAuth
How do I write this middleware? Do I need to continue laravel auth?
Also, let's look at the process;
Visitor accessoperator/index_1.html
MiddlewareOperatorAuth
Log On. return after Successful Logonoperator/index_1.html
Visitor accessoperator/index_2.html
MiddlewareOperatorAuth
Log On. return after Successful Logonoperator/index_2.html
After the middleware verification is successful, the access address is returned. How can this be written in the middleware?
Is there any elegant code written by laravel? I saw a lot of code written by laravel very beautiful. The code I wrote is ugly.
Please give me some guidance. I have a low IQ.
First, the command line:
php artisan make:middleware FrontEndOperatorAuth
Second, findapp/Http/Middlewares
FolderFrontEndOperatorAuth.php
, Inhandle()
Method to write your logic:
public function handle($request, Closure $next) { $user = $request->user(); if ( $user && $user->isOperator() ) { return $next($request); } return redirect()->back(); }
ThirdUser.php
AddisOperator()
:
public function isOperator(){ // your logic goes here}
Btw. You want to modify the typos.
Then I recently launched a laravel community: Laravist. If you have any questions about laravel, please come and ask me.