O
O
onlinejunior2020-07-14 08:39:18
Laravel
onlinejunior, 2020-07-14 08:39:18

How to create an extra empty entry in another laravel table?

In general, everything works for me, everything creates, but when auto authorization pops up an error like:

Argument 1 passed to Illuminate\Auth\SessionGuard::login() must implement interface Illuminate\Contracts\Auth\Authenticatable, instance of Illuminate\Http\RedirectResponse given

File RegisterController.php

protected function create

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

        $user = new Book();
        $user->user_id = $model->id;
        $user->save();

return Redirect::to('/home');

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Shubnikov, 2020-07-14
@onlinejunior

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

        $user = new Book();
        $user->user_id = $model->id;
        $user->save();

        return $model;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question