Browse Source

Merge pull request 'dev-wahyun' (#183) from dev-wahyun into staging

Reviewed-on: ordo/adw-backend#183
pull/3/head
ibnu 1 year ago
parent
commit
6599771ec7
  1. 23
      app/Http/Controllers/HumanResourceController.php

23
app/Http/Controllers/HumanResourceController.php

@ -10,7 +10,8 @@ use Illuminate\Support\Facades\Artisan;
class HumanResourceController extends Controller
{
public function add(Request $request){
public function add(Request $request)
{
$this->validate($request, [
'role_id' => 'required',
'name' => 'required',
@ -33,7 +34,8 @@ class HumanResourceController extends Controller
}
}
public function edit($id){
public function edit($id)
{
if (!$id || (int) $id < 0 || $id == "") {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
die();
@ -48,7 +50,8 @@ class HumanResourceController extends Controller
}
}
public function update(Request $request, $id){
public function update(Request $request, $id)
{
if (!$id || (int) $id < 0 || $id == "") {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
@ -112,7 +115,7 @@ class HumanResourceController extends Controller
public function list()
{
$data = HumanResource::select('id', 'name')->get();
$data = HumanResource::select('id', 'name', 'role_id')->get();
$countData = $data->count();
if ($data) {
@ -122,7 +125,8 @@ class HumanResourceController extends Controller
}
}
public function select(Request $request){
public function select(Request $request)
{
$search = $request->query('search');
@ -177,17 +181,16 @@ class HumanResourceController extends Controller
$data['old_password'] = md5($request->old_password);
if ($data['old_password'] !== $result->password) {
return response()->json(['status' => 'failed', 'message' => "old password seems doesn't match in records. please try again.", 'code' => 400], 400);
}
elseif($data['old_password'] === $result->password) {
} elseif ($data['old_password'] === $result->password) {
return response()->json(['status' => 'success', 'message' => "old password match", 'data' => $result, 'code' => 200], 200);
}
}
else {
} else {
return response()->json(['status' => 'failed', 'message' => 'old_password is required!', 'code' => 400], 400);
}
}
public function sync(){
public function sync()
{
Artisan::call('sync:integration-human-resources');
}
}

Loading…
Cancel
Save