2017-08-13 55 views
-2

当我注册证明这个错误-----级“应用程序学生找不到

Class 'app\Student' not found 
in CustomLoginController.php (line 57) 

代码:

<?php 

namespace App\Http\Controllers; 

use Illuminate\Http\Request; 

use Illuminate\Support\Facades\Validator; 

use app\Student; 

use Redirect; 

use Session; 

use Illuminate\Support\Facades\Input; 

class CustomLoginController extends Controller 

{ 

public function ShowLoginForm() 

{ 
    return view('custom.login'); 
} 
public function login(Request $request) 
{ 
    return 'login'; 
} 
public function ShowRegisterForm() 

{ 

    return view('custom.register'); 

} 

public function register(Request $request) 

{ 

    $rules = array(

     'first_name' => 'required|min:5', 

     'last_name' => 'required|min:5', 

     'email'   => 'required|email|unique:students',  // required and must be unique in the students table 
     'password'   => 'required|min:6', 
     'password_confirm' => 'required|same:password' 
    ); 
    $messages = [ 
     'first_name.required' => 'Please enter first name.', 
     'first_name.min' => 'First name should be atleast 5 characters.', 
     'last_name.required' => 'Please enter last name.', 
     'last_name.min' => 'Last name should be atleast 5 characters.', 
     'email.required' => 'Please enter email address.', 
     'email.email' => 'Please enter a valid email address.', 
     'email.unique' => 'This email address has been already used. Please try another', 
     'password.required' => 'Please enter password.', 
     'password.min' => 'Password should be atleast 6 characters.', 
     'password_confirm.required' => 'Please enter confirm password.', 
     'password_confirm.same' => 'Password do not match.', 
    ]; 

    $validator = Validator::make(Input::all(), $rules ,$messages); 

    if ($validator->fails()) { 
     return redirect('/custom-register') 
       ->withErrors($validator) 
       ->withInput(Input::except('password', 'password_confirm')); 
    } 

    $students = new Student(); 
    $students->first_name = Input::get('first_name'); 
    $students->last_name = Input::get('last_name'); 
    $students->email = Input::get('email'); 
    $students->password = Hash::make(Input::get('password')); 
    $students->save(); 

    // Auth::login($students); 
    return redirect()->route('/'); 
} 
} 
+0

请帮助我。我刚开始学习laravel 5.4。 – Rocky

+0

类'app \ Student'根本不存在。 –

回答

0

应该App\Studentapp\Student

+0

感谢@Rabah G – Rocky

+0

它的工作原理。这是一个愚蠢的错误。 – Rocky

相关问题