diff --git a/app/Http/Controllers/HumanResourceController.php b/app/Http/Controllers/HumanResourceController.php index 1cbee8b..14c44fa 100644 --- a/app/Http/Controllers/HumanResourceController.php +++ b/app/Http/Controllers/HumanResourceController.php @@ -3,7 +3,6 @@ namespace App\Http\Controllers; use App\Models\User; -use Illuminate\Support\Str; use App\Models\UserToProyek; use Illuminate\Http\Request; use App\Models\HumanResource; @@ -18,15 +17,15 @@ class HumanResourceController extends Controller public function add(Request $request) { $this->validate($request, [ - 'role_id' => 'required', 'name' => 'required', 'ktp_number' => 'required|string|unique:m_users,ktp_number', 'employee_type' => 'required', 'company_id' => 'required', - 'username' => 'unique:m_users,username' + 'username' => 'unique:m_users,username', ]); $data = $request->all(); + !$request->is_customer ? $this->validate($request,['role_id'=>'required','divisi_id'=>'required']) : ''; if (isset($request->password) && $request->password != "") { $data['password'] = md5($request->password); @@ -113,6 +112,8 @@ class HumanResourceController extends Controller public function update(Request $request, $id) { + !$request->is_customer ? $this->validate($request,['role_id'=>'required','divisi_id'=>'required']) : ''; + if (!$id || (int) $id < 0 || $id == "") { return response()->json(['status' => 'failed', 'message' => 'Id is required!', 'code' => 400], 400); }