Hash :: make在laravel 5.0 Controller中不起作用

时间:2015-02-20 06:00:42

标签: laravel laravel-5

我在laravel 5.0上的新功能看到错误http://i.stack.imgur.com/4ZMgZ.png 这是我的控制器代码

<?php namespace App\Http\Controllers;
use Illuminate\Support\Facades\Input;
class DealerController extends Controller {

    public function __construct(){
        //$this->middleware('auth');
    }

    public function login(){
        return view('login');
    }

    public function index() {
        return view('login');

    }
    public function login_auth(){
        $dealer_loginname = Input::get('dealer_loginname');
        $dealer_password = Input::get('dealer_password');
        $dealer_hashed_pass = Hash::make($dealer_password);

    }
}

我Hash :: make在composer cmd中运行正常 http://i.stack.imgur.com/SqdYs.jpg,它也适用于路线文件

//Route::post('dealerpanel/login_auth','DealerController@login_auth');
Route::post('dealerpanel/login_auth',function (){
    $pass = Hash::make('abc');
    die($pass);
    //$2y$10$lSG0Dl3NCJ0ubWIwILzPk.SFGeLmwkw03v3NZ5yMgkg4fAry1Cjc2
});

1 个答案:

答案 0 :(得分:31)

因为您使用的命名空间似乎没有导入Hash

尝试添加

use Hash;

位于DealerController文件之上,如

<?php namespace App\Http\Controllers;

    use Illuminate\Support\Facades\Input;
    use Hash;

    class DealerController extends Controller {

    public function __construct(){....

或只是使用

$pass = \Hash::make('abc');