Laravel-无需登录即可认证用户 - php

在laravel 5.4中,可以在不登录用户的情况下对用户进行身份验证吗?从laravel doc中,我能找到的最接近的东西是:

Auth::once($credentials)

但这仍然使该用户感到厌烦。我需要做的就是只是知道使用该电子邮件和密码的用户是否存在。

参考方案

您可以将Auth::attempt函数与第三个参数用作false进行登录

 $email=$request->email;
 $password=$request->password;
 if(Auth::attempt(['email'=>$email, 'password'=>$password],false,false))
   {
        echo "found":
    }else {
        echo "not found";
   }

选中此https://laravel.com/api/5.1/Illuminate/Auth/Guard.html#method_attempt

或使用Auth::validate

https://laravel.com/api/5.1/Illuminate/Auth/Guard.html#method_validate

Laravel Blade模板尝试获取非对象的属性时如何返回null而不是ErrorException - php

我正在编写一些Laravel Blade模板,并且我的模型可能包含空对象。我非常想尝试获取对象属性,如果有错误,则返回null。因此,不必编写以下代码:@if ($model->child_object_that_may_be_null) {{ $model->child_object_that_may_be_null->interesti…

Laravel 5错误报告抑制 - php

在Laravel 4中,抑制E_NOTICE消息很容易;我似乎无法做到这一点,因为如果我添加error_reporting(E_ALL ^ E_NOTICE) 它只是被覆盖的任何地方。这似乎发生在这里:(index.php)$response = $kernel->handle( $request = Illuminate\Http\Request::…

Laravel-使用雄辩的语言在开始日期和结束日期之间选择行 - php

我想将此查询转换为雄辩的laravel,select * from schedule where (now() between start_date and end_date); 我尝试使用whereBetween,但是出现了一些错误。$schedule = Schedule::whereBetween(Carbon::now(), ['start…

PHP Laravel从另一个驱动器读取文件 - php

我目前正在学习Laravel。我想知道是否有一种方法可以在Laravel中使用Storage::从另一个硬盘访问文件(使用Windows)。例如,我在驱动器C:上安装了带有Laravel的Xampp,但是我想访问网站目录之外的E:上的文件。我试过使用Storage::files('E:')和File::files('E:…

检查对象是否已在集合中-Laravel - php

当我循环一系列不同的结果时,我希望将对象添加到新集合中。查询:$osRed = Item::where('category', 'Hardware') ->where(function ($query) { $query->where('operating_system', '…