Commit 74c5cf48f714708e9cfeae28d4a6cc91f5f3e164
1 parent
ef85e20c2a
Exists in
master
fix worker register error
Showing 1 changed file with 10 additions and 7 deletions Side-by-side Diff
app/Http/Controllers/WorkerController.php
... | ... | @@ -703,23 +703,26 @@ class WorkerController extends Controller |
703 | 703 | 'telephone' => $data['telephone'], |
704 | 704 | 'password' => Hash::make($data['password']), |
705 | 705 | 'pubpassword' => base64_encode($data['password']), |
706 | -// 'email_verified_at' => Carbon::now(), | |
707 | 706 | 'is_worker' => $data['is_worker'], |
708 | 707 | ]); |
709 | 708 | |
710 | 709 | if ($Code_user->id > 0) { |
711 | 710 | $Worker = new Worker(); |
712 | 711 | $Worker->user_id = $Code_user->id; |
713 | - $Worker->position_work = $data['job_titles']; | |
712 | + $Worker->position_work = $data['job_titles'] ?? null; | |
714 | 713 | $Worker->email = $data['email']; |
715 | 714 | $Worker->telephone = $data['telephone']; |
716 | 715 | $Worker->save(); |
717 | 716 | |
718 | - if (isset($Worker->id)) { | |
719 | - $Title_Worker = new Title_worker(); | |
720 | - $Title_Worker->worker_id = $Worker->id; | |
721 | - $Title_Worker->job_title_id = $data['job_titles']; | |
722 | - $Title_Worker->save(); | |
717 | + if (isset($Worker->id) && !empty($data['job_titles'])) { | |
718 | + $existJob = Job_title::query()->find($data['job_titles']); | |
719 | + if ($existJob) { | |
720 | + $Title_Worker = new Title_worker(); | |
721 | + $Title_Worker->worker_id = $Worker->id; | |
722 | + $Title_Worker->job_title_id = $data['job_titles']; | |
723 | + $Title_Worker->save(); | |
724 | + } | |
725 | + | |
723 | 726 | } |
724 | 727 | |
725 | 728 | return $Code_user; |