input('client_uuid'); $userId = \Auth::user()->id; $pReqPer = $request->input('person'); $pReqCont = $request->input('contract'); $cid = \DB::table('person')->where('uuid', $cuuid)->firstOrFail('id')->id; if(!empty($cid)){ $pid = \App\Models\Person\Person::create([ 'nu' => rand(100000,200000), 'first_name' => $pReqPer['first_name'], 'last_name' => $pReqPer['last_name'], 'full_name' => $pReqPer['full_name'], 'gender' => null, 'birthday' => null, 'tax_number' => null, 'social_security_number' => null, 'description' => 'sdwwf', 'group_id' => 2, 'type_id' => 1, 'user_id' => $userId ])->id; $address = [ 'address' => $pReqPer['address']['address'], 'country' => $pReqPer['address']['country'], 'type_id' => $pReqPer['address']['type_id'], 'person_id' => $pid, 'user_id' => $userId ]; $contract = [ 'reference' => $pReqCont['reference'], 'start_date' => date('Y-m-d', strtotime($pReqCont['start_date'])), 'client_id' => $cid, 'debtor_id' => $pid, 'type_id' => $pReqCont['type_id'] ]; \App\Models\Person\PersonAddress::create($address); \App\Models\Contract::create($contract); } return to_route('client.show', ['uuid' => $cuuid]); } }