Laravel - 没有关于模型的查询结果

时间:2015-04-24 22:29:38

标签: php laravel eloquent

我遇到错误'没有模型[App \ User]的查询结果。',当我试图找到有此查询的用户时。

        if(User::where('email', '=', Request::only('email'))->firstOrFail()){
        $validator->errors()->add(...);
    }

1 个答案:

答案 0 :(得分:2)

$ sw_vers -productVersion 10.9.5 $ sudo ifconfig vlan169 create && echo vlan169 created vlan169 created $ sudo ifconfig vlan169 inet 169.254.169.254 netmask 255.255.255.255 && echo vlan169 configured vlan169 configured $ sudo ./minidns.py 169.254.169.254 & [1] 35125 $ miniDNS :: * 60 IN A 169.254.169.254 $ dig @169.254.169.254 +short test.host Request: test.host. -> 169.254.169.254 Request: test.host. -> 169.254.169.254 169.254.169.254 $ sudo kill 35125 $ [1]+ Exit 143 sudo ./minidns.py 169.254.169.254 $ sudo ifconfig vlan169 destroy && echo vlan169 destroyed vlan169 destroyed 实际上将返回一个数组。在您的情况下:Request::only()。要么这样做:

['email' => 'the-value-of-email']

或者只使用User::where(Request::only('email'))->firstOrFail() 来检索值:

Request::input()