第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

類 RedirectIfPasswordNotUpdated 不存在

類 RedirectIfPasswordNotUpdated 不存在

PHP
慕斯709654 2021-10-15 16:06:11
我使用以下命令創(chuàng)建了一個(gè)自定義中間件php artisan make:middleware RedirectIfPasswordNotUpdated這是我的中間件<?phpnamespace App\Http\Middleware;use Closure;use Carbon\Carbon;use Illuminate\Support\Facades\Auth;use App;class RedirectIfPasswordNotUpdated{    public function handle($request, Closure $next)    {        if (!App::environment(['production'])) {            return $next($request);        }        $user = Auth::user();        if (!$user->password_updated_at) {            return redirect()->route('profile.password.edit')->with([                'message' => 'Please update your password to proceed',                'alertType' => 'warning',            ]);        }        if (Carbon::now()->diffInDays(Carbon::parse($user->password_updated_at)) > 90) {            return redirect()->route('profile.password.edit')->with([                'message' => 'Your password has expired! Please update your password to proceed',                'alertType' => 'warning',            ]);        }        return $next($request);    }}我想在我的控制器的構(gòu)造函數(shù)中使用這個(gè)中間件,如下所示public function __construct(){    $this->middleware('auth');    $this->middleware('RedirectIfPasswordNotUpdated');}當(dāng),我這樣做時(shí),我得到一個(gè)ReflectionException (-1)說Class RedirectIfPasswordNotUpdated does not exist我在其他 Laravel(v5.4、v5.6)項(xiàng)目中以相同的方式使用這個(gè)中間件,并且沒有任何問題。但它在當(dāng)前版本 (v5.8) 中不起作用。我究竟做錯(cuò)了什么?
查看完整描述

1 回答

?
搖曳的薔薇

TA貢獻(xiàn)1793條經(jīng)驗(yàn) 獲得超6個(gè)贊

正如我所看到的,您尚未注冊(cè)您middleware class的app\Http\Kernel.php. 注冊(cè)一個(gè)中間件非常簡單,如下所示:


protected $routeMiddleware = [

   'middle_name' => \App\Http\Middleware\RedirectIfPasswordNotUpdated::class,

]


查看完整回答
反對(duì) 回復(fù) 2021-10-15
  • 1 回答
  • 0 關(guān)注
  • 131 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)