diff --git a/app/Http/Controllers/Company/Employee/EmployeeEditController.php b/app/Http/Controllers/Company/Employee/EmployeeEditController.php index 496523fb0..75fec4b4b 100644 --- a/app/Http/Controllers/Company/Employee/EmployeeEditController.php +++ b/app/Http/Controllers/Company/Employee/EmployeeEditController.php @@ -59,6 +59,7 @@ public function show(Request $request, int $companyId, int $employeeId) 'last_name' => $employee->last_name, 'name' => $employee->name, 'email' => $employee->email, + 'phone' => $employee->phone_number, 'birthdate' => (! $employee->birthdate) ? null : [ 'year' => $employee->birthdate->year, 'month' => $employee->birthdate->month, @@ -96,6 +97,7 @@ public function update(Request $request, int $companyId, int $employeeId): JsonR 'first_name' => $request->input('first_name'), 'last_name' => $request->input('last_name'), 'email' => $request->input('email'), + 'phone' => $request->input('phone'), ]; (new SetPersonalDetails)->execute($data); diff --git a/app/Http/ViewHelpers/Employee/EmployeeShowViewHelper.php b/app/Http/ViewHelpers/Employee/EmployeeShowViewHelper.php index dc532afba..8cc14d2a5 100644 --- a/app/Http/ViewHelpers/Employee/EmployeeShowViewHelper.php +++ b/app/Http/ViewHelpers/Employee/EmployeeShowViewHelper.php @@ -34,6 +34,7 @@ public static function informationAboutEmployee(Employee $employee, array $permi 'last_name' => $employee->last_name, 'avatar' => $employee->avatar, 'email' => $employee->email, + 'phone' => $employee->phone_number, 'twitter_handle' => $employee->twitter_handle, 'slack_handle' => $employee->slack_handle, 'locked' => $employee->locked, diff --git a/app/Models/Company/Employee.php b/app/Models/Company/Employee.php index d0dfe666f..473bbf28f 100644 --- a/app/Models/Company/Employee.php +++ b/app/Models/Company/Employee.php @@ -50,6 +50,7 @@ class Employee extends Model 'consecutive_worklog_missed', 'employee_status_id', 'uuid', + 'phone_number', 'locked', 'avatar', 'holiday_balance', diff --git a/app/Services/Company/Employee/PersonalDetails/SetPersonalDetails.php b/app/Services/Company/Employee/PersonalDetails/SetPersonalDetails.php index 5c591a7bc..e66f2ee98 100644 --- a/app/Services/Company/Employee/PersonalDetails/SetPersonalDetails.php +++ b/app/Services/Company/Employee/PersonalDetails/SetPersonalDetails.php @@ -27,6 +27,7 @@ public function rules(): array 'first_name' => 'required|string|max:255', 'last_name' => 'required|string|max:255', 'email' => 'required|email:rfc|max:255', + 'phone' => 'nullable|max:255', ]; } @@ -63,6 +64,7 @@ private function save(array $data): void $this->employee->first_name = $data['first_name']; $this->employee->last_name = $data['last_name']; $this->employee->email = $data['email']; + $this->employee->phone_number = $data['phone']; $this->employee->save(); } diff --git a/database/factories/CompanyFactory.php b/database/factories/CompanyFactory.php index 7fa9ecc2f..c3b535ac0 100644 --- a/database/factories/CompanyFactory.php +++ b/database/factories/CompanyFactory.php @@ -30,6 +30,7 @@ 'avatar' => 'https://api.adorable.io/avatars/285/abott@adorable.png', 'permission_level' => config('officelife.permission_level.administrator'), 'email' => 'dwigth@dundermifflin.com', + 'phone_number' => '1234567', 'first_name' => 'Dwight', 'last_name' => 'Schrute', 'birthdate' => $faker->dateTimeThisCentury()->format('Y-m-d H:i:s'), diff --git a/database/migrations/2020_11_01_211117_add_phone_number_to_employees.php b/database/migrations/2020_11_01_211117_add_phone_number_to_employees.php new file mode 100644 index 000000000..51cb35baf --- /dev/null +++ b/database/migrations/2020_11_01_211117_add_phone_number_to_employees.php @@ -0,0 +1,21 @@ +string('phone_number')->after('uuid')->nullable(); + }); + } +} diff --git a/resources/js/Pages/Employee/Edit.vue b/resources/js/Pages/Employee/Edit.vue index d96529e1d..cf3a1a011 100644 --- a/resources/js/Pages/Employee/Edit.vue +++ b/resources/js/Pages/Employee/Edit.vue @@ -1,7 +1,7 @@