Laravel 5.1中未找到类错误

hel*_*rld 2 php laravel

嘿伙计们,我正在尝试学习PHP框架以及OOP,我正在使用Laravel 5.1 LTS.

我的代码中包含以下代码 AuthController

<?php

namespace App\Http\Controllers\Auth;

use App\Verification;
use Mail;
use App\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;

class AuthController extends Controller
{

    use AuthenticatesAndRegistersUsers, ThrottlesLogins;
    private $redirectTo = '/home';
    public function __construct()
    {
        $this->middleware('guest', ['except' => 'getLogout']);
    }

    protected function validator(array $data)
    {
        return Validator::make($data, [
            'name' => 'required|max:255',
            'email' => 'required|email|max:255|unique:users',
            'password' => 'required|confirmed|min:6',
        ]);
    }

    protected function create(array $data){
        $user = User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => bcrypt($data['password']),
        ]);

        // generate our UUID confirmation_code
        mt_srand((double)microtime()*15000);//optional for php 4.2.0 and up.
        $charid = strtoupper(md5(uniqid(rand(), true)));
        $uuid = substr($charid, 0, 8)
        .substr($charid, 8, 4)
        .substr($charid,12, 4)
        .substr($charid,16, 4)
        .substr($charid,20,12);

        $data['confirmation_code'] = $uuid;

        // pass everything to the model here 
        $setVerification = new Verification();
        $setVerification->setVerificationCode($data['email'], $data['confirmation_code']);

        // send email for confirmation
        Mail::send('email.test', $data, function ($m) use ($data){
            $m->from('test@test.com', 'Your Application');
            $m->to($data['email'])->subject('Thanks for register! Dont forget to confirm your email address');
        });

        return $user;

    }

}
Run Code Online (Sandbox Code Playgroud)

我的错误消息Class 'Models\Verification' not found来自这段代码

// pass everything to the model here 
$setVerification = new Verification();
$setVerification->setVerificationCode($data['email'], $data['confirmation_code']);
Run Code Online (Sandbox Code Playgroud)

看起来对我的初学者来说是正确的,但这显然是错误的.

这是我的Verification班级setVerificationCode method

<?php 

namespace App\Http\Controllers;

use App\User;
use DB;
use App\Http\Controllers\Controller;

class Verification {

    /**
     * This method will update the confirmation_code column with the UUID
     * return boolean
     **/
    protected function setVerificationCode($email, $uuid) { 
        $this->email = $email;
        $this->uuid = $uuid;

        // check to see if $email & $uuid is set    
        if (isset($email) && isset($uuid)) {
            DB::table('users')
                    ->where('email', $email)
                    ->update(['confirmation_code' => $uuid]);

            return TRUE;
        } else {
            return FALSE;
        }
    }

    /**
     * This method will validate if the UUID sent in the email matches with the one stored in the DB
     * return boolean
     **/
    protected function verifyConfirmationCode() {

    }


}
Run Code Online (Sandbox Code Playgroud)

Has*_*P A 6

请在AuthController中提供以下内容

使用App\Http\Controllers\Verification;

代替

使用App\Verification;

如果我们使用App\Verification,它将检查是否有任何名为Verification的模型.