小编Goo*_*Day的帖子

Auth()->user() 或 Auth::user() 返回错误的用户数据

我面临一个独特的问题,我的数据库中只有 3 个用户数据 John、Cindy 和 Carla,我使用用户名 john 登录,但我得到 Carla 的身份验证数据,它应该是 john 的身份验证数据。

这是我的登录功能LoginController.php

public function login(Request $request) {
    $this->validateLogin($request);
    $credentials = ['user_id' => \Arr::get('user_id','', $request->input('user_id')),                  
        'password' => \Arr::get('password','', $request->input('user_password'))
    ]; 

    if(Auth::attempt($credentials)){
        return  redirect()->intended($this->redirectPath());
    }

    return back()->withInput($request->except('password'))->withErrors(['Username atau Password Wrong! ']);
}
Run Code Online (Sandbox Code Playgroud)

这是我的用户模型

class User extends Authenticatable {
    use Notifiable;
    use HasRoles;

    protected $table = "m_user";
    protected $primaryKey = "user_id";

    public function getAuthPassword() {
        return $this->hash_password;
    }

    protected $fillable = [
        'user_id', 'nama', 'user_password','hash_password','role', 'company','is_active','created_by','created_at','updated_by','updated_at'
    ];

    protected …
Run Code Online (Sandbox Code Playgroud)

laravel eloquent

5
推荐指数
1
解决办法
939
查看次数

如何在module.exports中访问对象属性

我很好奇如何访问module.exports中的另一个对象属性.

这是案例:

module.exports = {

    text: 'abcd',
    index: (req, res)=>{
    console.log(text) <-- is not defined
    console.log(this.text) <-- undefined
    }
}
Run Code Online (Sandbox Code Playgroud)

那么,如何访问文本属性?谢谢你们需要你的解释.

javascript object javascript-objects express

2
推荐指数
1
解决办法
1334
查看次数

如何仅查看猫鼬中的值的第一个字母来查找所有文档

我想按首字母查找所有文档。

情况是当我在mysql中查询时我可以做 WHERE Stores LIKE 'a%'

the result would be all data with the first letter a.
Run Code Online (Sandbox Code Playgroud)

问题是:

  • 如何使同样的query使用mongoose
  • 怎么样case-sensitive eg: (a,A)。这将是相同的查询与否?
  • 是否有必要lowercase_field为这种情况创建?

mongoose mongodb mongodb-query mongoose-populate mongoose-schema

0
推荐指数
1
解决办法
1520
查看次数

无法打开 /var/folders/n_/laravel-excel.maatwebsite

我想使用 laravel-excel.maatwebsitelibrary 创建下载 excel 功能。我的代码如下:

return Excel::download(new PembukuanExport, 'pembukuan.xlsx');
Run Code Online (Sandbox Code Playgroud)

但是当我运行它时,它给了我这样的错误

无法打开 /var/folders/n_/xh_10hm50dvbwg23cfq_kw3h0000gn/T/laravel-excel-DMBN3reNUrSiamYT 进行写入。

在此处输入图片说明

我的笔记本电脑是 macbook,一直在谷歌搜索但找不到正确的答案

laravel laravel-excel maatwebsite-excel

0
推荐指数
1
解决办法
2545
查看次数