Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我该如何保持一致性?拉威尔。我想在生成新用户时插入有关用户的数据_Php_Laravel - Fatal编程技术网

Php 我该如何保持一致性?拉威尔。我想在生成新用户时插入有关用户的数据

Php 我该如何保持一致性?拉威尔。我想在生成新用户时插入有关用户的数据,php,laravel,Php,Laravel,我应该如何保持一致性? 我想在注册新用户时对另一个表进行“插入” 桌子 用户 //数据等于已验证的请求 'name' => $data['name'], 'email' => $data['email'], 'profile' => $data['profile'], 'adress' => $data['adress'] 附加表 worker\u id具有用户\u id的外

我应该如何保持一致性? 我想在注册新用户时对另一个表进行“插入”

桌子 用户 //数据等于已验证的请求

            'name' => $data['name'],
            'email' => $data['email'],
            'profile' => $data['profile'],
            'adress' => $data['adress']
附加表 worker\u id具有用户\u id的外键

'worker_id' =>  $user->id,  
'place' => $request->place
Laravel认证寄存器

public function register(Request $request)
    {
        $this->validator($request->all())->validate();

        event(new Registered($user = $this->create($request->all())));

        if($request->user_type == 1)
        {
            DB::table('additional')->updateOrInsert(
                ['worker_id' =>  $user->id,  
                ['place' => $request->place)]
            );
        }
        $this->guard()->login($user);

        if ($response = $this->registered($request, $user)) {
            return $response;
        }

        return $request->wantsJson()
                    ? new Response('', 201)
                    : redirect($this->redirectPath());
    }

以下是一些可能有效的方法:

DB::table('additional')->insertOrIgnore([
    ['worker_id' => $user->id, 'place' => $request->place]
]);

以下是一些可能有效的方法:

DB::table('additional')->insertOrIgnore([
    ['worker_id' => $user->id, 'place' => $request->place]
]);

首先进行选择和检查,如果没有,则插入..有什么不起作用吗<代码>['worker\u id'=>$user->id,['place'=>$request->place)]看起来它的括号太多了。首先选择并检查,如果没有,然后插入..有些东西不起作用吗?
['worker\u id'=>$user->id,['place'=>$request->place]
看起来它的括号太多了