Hash::make 在 Laravel 5.0 控制器中不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28622569/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 16:53:06  来源:igfitidea点击:

Hash::make not working in laravel 5.0 Controller

laravellaravel-5

提问by user3151197

I new on laravel 5.0 see error http://i.stack.imgur.com/4ZMgZ.pngHere is my controller code

我在 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);

    }
}

I Hash::make works fine in composer cmd http://i.stack.imgur.com/SqdYs.jpgand its also work on routes file

我 Hash::make 在作曲家 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);
    //y$lSG0Dl3NCJ0ubWIwILzPk.SFGeLmwkw03v3NZ5yMgkg4fAry1Cjc2
});

回答by Kalhan.Toress

seems like you didn't import Hashsince your using namespaces.

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

try to add

尝试添加

use Hash;

on top of the DealerControllerfile like,

DealerController文件顶部,例如,

<?php namespace App\Http\Controllers;

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

    class DealerController extends Controller {

    public function __construct(){....

or just use

或者只是使用

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