Get the App
SLTechnology News&Howtos  ›  Development  › 

How to partially exclude Middleware in laravel

Shulou Source: shulou.com Published: 2022-06-03 03:00:33 10月27日 Update

This article introduces the relevant knowledge of "how to partially exclude middleware in laravel". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

One method to deal with logged-in and non-logged-in users

Api file / / client interface Route::prefix ('client')-> group (function () {Route::apiResource (' applys', 'ApplysController'); / / the interface requiring login authorization / / multiauth:member_api middleware registers Route::group globally ([' middleware' = > ['multiauth:member_api',' check.member']], function () {}); controller settings private $flag Public function _ construct (Request $request) {$this- > flag = false; / / determine whether there is a token if (array_key_exists ('authorization',$request- > header ()) {$this- > middleware ([' multiauth:member_api', 'check.member']);} else {$this- > flag = true $this- > middleware (['multiauth:member_api',' check.member'], ['except' = >' index']);}} "how laravel partially excludes middleware" ends here, thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Middleware user login local content interface more knowledge practicality learning next token global dilemma reality situation controller file article method Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Microsoft Docker vpn Redmi