简体   繁体   English

注册错误,参数1传递给laravel 5.8中的Illuminate \\ Auth \\ SessionGuard :: login()

[英]Registration error, Argument 1 passed to Illuminate\Auth\SessionGuard::login() in laravel 5.8

Modify my registration blade. 修改我的注册刀片。 I added 2 additional functions that trigger the registration of the user. 我添加了2个附加功能来触发用户注册。 The data I needed are being saved to the appropriate tables but I am having this error, 我需要的数据已保存到适当的表中,但出现此错误,

Argument 1 passed to Illuminate\\Auth\\SessionGuard::login() must implement interface Illuminate\\Contracts\\Auth\\Authenticatable, boolean given, called in E:\\wamp64\\www\\aftscredit-appzcoder\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Auth\\RegistersUsers.php on line 35 传递给Illuminate \\ Auth \\ SessionGuard :: login()的参数1必须实现接口Illuminate \\ Contracts \\ Auth \\ Authenticatable,给定布尔值,在E:\\ wamp64 \\ www \\ aftscredit-appzcoder \\ vendor \\ laravel \\ framework \\ src \\ Illuminate中调用第35行的\\ Foundation \\ Auth \\ RegistersUsers.php

Here's my Registration controller 这是我的注册控制器

<?php

namespace App\Http\Controllers\Auth;

use App\User;
use App\Referral;
use App\CollectorMember;
use App\HasRoles;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Http\Request;

class RegisterController extends Controller
{
    use RegistersUsers;

    protected $redirectTo = '/home';


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

    public function index(Request $request)
    {
        $referral = '';
        $keyword = $request->get('search');
        $referral = Referral::where([
                         ['code', $keyword],
                         ['status', 0]
                         ])->first();        

        if (is_null($keyword))
            return view ( 'Auth.register');
        elseif ($referral)
            return view ( 'Auth.register', compact('referral', $referral))
                                    ->withDetails ( $referral )
                                    ->withQuery ( $keyword );
        else 
            return view ( 'Auth.register')->withMessage ( 'The code you provided is not EXISTING or not AVAILABLE.' );
    }

    protected function validator(array $data)
    {
        return Validator::make($data, [
            'name' => ['required', 'string', 'max:255'],
            'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
            'password' => ['required', 'string', 'min:8', 'confirmed'],
        ]);
    } 

    protected function create(array $data)
    {

        $user = User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => Hash::make($data['password']),
        ]);

        $user_id = $user->id;

        Referral::find($data['referral_id'])->update ([
            'status'    => 1,
            'date_used' => $data['referral_date_used']
        ]);


        return CollectorMember::create ([
            'collector_id' => $data['referral_generate_by'],
            'borrower_id'  => $user_id,
            'referral_id'  => $data['referral_id'],
        ]);

    }
}

What's causing this? 是什么原因造成的? thanks in advance! 提前致谢!

Try opening the RegistersUsers trait and look at line 35. A user is not being created. 尝试打开RegistersUsers特性并查看第35行。没有创建用户。

The original Laravel controller code to create a user is as follows: 创建用户的原始Laravel控制器代码如下:

    /**
     * Create a new user instance after a valid registration.
     *
     * @param  array  $data
     * @return \App\User
     */
    protected function create(array $data)
    {
        return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => Hash::make($data['password']),
        ]);
    }

Note how the DocBlock indicates an instance of User must be returned. 请注意DocBlock如何指示必须返回User的实例。 This is key because the the actual code that completes the registration, within the trait, assumes aa valid User model instance. 这是关键,因为在特征内完成注册的实际代码假定一个有效的User模型实例。

It's sometimes helpful to step through the code and understand what Laravel is doing for you, behind the scenes. 在幕后逐步浏览代码并了解Laravel为您所做的工作有时会很有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在laravel 5.8注册期间添加ROLE时,参数1传递给Illuminate \\ Auth \\ SessionGuard :: login() - Argument 1 passed to Illuminate\Auth\SessionGuard::login() when adding ROLE during registration in laravel 5.8 LARAVEL 7.0 传递给 Illuminate\\Auth\\SessionGuard::login() 的参数 1 必须实现接口 Illuminate\\Contracts\\Auth\\Authenticatable,给定数组 - LARAVEL 7.0 Argument 1 passed to Illuminate\Auth\SessionGuard::login() must implement interface Illuminate\Contracts\Auth\Authenticatable, array given 类型错误:参数1传递给Illuminate \\ Auth \\ SessionGuard :: login()寄存器上的重定向不起作用 - Type error: Argument 1 passed to Illuminate\Auth\SessionGuard::login() redirection on register does not work 社交名流:传递给 Illuminate\Auth\SessionGuard::login() 的参数 1 必须实现接口 Illuminate\Contracts\Auth\Authenticatable,给定 null - Socialite : Argument 1 passed to Illuminate\Auth\SessionGuard::login() must implement interface Illuminate\Contracts\Auth\Authenticatable, null given Laravel 8:传递给 Illuminate\Auth\SessionGuard::__construct() 的参数 2 必须是 Illuminate\Contracts\Auth\UserProvider 的实例,null 给定 - Laravel 8 : Argument 2 passed to Illuminate\Auth\SessionGuard::__construct() must be an instance of Illuminate\Contracts\Auth\UserProvider, null given 传递给SessionGuard :: login()的参数1必须是Laravel 5.2中Auth \\ Authenticatable的实例 - Argument 1 passed to SessionGuard::login() must be an instance of Auth\Authenticatable in Laravel 5.2 Illuminate\Auth\SessionGuard::login(): 参数 #1 ($user) 必须是类型 - Illuminate\Auth\SessionGuard::login(): Argument #1 ($user) must be of type Laravel 错误:方法 Illuminate\\Auth\\SessionGuard::venue 不存在 - Laravel Error: Method Illuminate\Auth\SessionGuard::venue does not exist Laravel 5.8多次授权注册和登录 - Laravel 5.8 multiple auth registration and login TypeError: Illuminate\Auth\SessionGuard::login(): 参数 #1 ($user) 必须是类型 Illuminate\Contracts\Auth\Authenticatable,, App\Models\Admin giv - TypeError: Illuminate\Auth\SessionGuard::login(): Argument #1 ($user) must be of type Illuminate\Contracts\Auth\Authenticatable,, App\Models\Admin giv
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM