如何在laravel控制器中从AdminAuthServiceProvider调用方法?

在AuthServiceProvider中,我在启动功能中有以下一行。

 Auth::provider('customer', function($app, array $config){     
     return new CustomerAuthServiceProvider();
 });

我需要从Controller中的CustomerAuthServiceProvider调用方法。我可以做吗 ?


largeQ
浏览 238回答 2
2回答

DIEA

createUserProvider该方法可通过以下Illuminate\Auth\CreatesUserProviders特征访问Illuminate\Auth\AuthManager您可以AuthManager通过Illuminate\Support\Facades\AuthFacade获取该类的实例。use Illuminate\Support\Facades\Auth;//...class WhatController extends Controller {   public function index()   {      $provider = Auth::createUserProvider('customer');   }}请注意, customer条目必须包含在以下位置的providers数组中config/auth.phpproviders' => [  //...  customer' => [   'driver' => 'eloquent',   'model' => App\WhatCustomer::class,  ]]
打开App,查看更多内容
随时随地看视频慕课网APP