Browse Source

add select role_id in HumanResourceController@list

pull/3/head
wahyuun 1 year ago
parent
commit
464407d9ee
  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 class HumanResourceController extends Controller
{ {
public function add(Request $request){ public function add(Request $request)
{
$this->validate($request, [ $this->validate($request, [
'role_id' => 'required', 'role_id' => 'required',
'name' => '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 == "") { if (!$id || (int) $id < 0 || $id == "") {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
die(); 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 == "") { if (!$id || (int) $id < 0 || $id == "") {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400);
@ -112,7 +115,7 @@ class HumanResourceController extends Controller
public function list() public function list()
{ {
$data = HumanResource::select('id', 'name')->get(); $data = HumanResource::select('id', 'name', 'role_id')->get();
$countData = $data->count(); $countData = $data->count();
if ($data) { if ($data) {
@ -122,7 +125,8 @@ class HumanResourceController extends Controller
} }
} }
public function select(Request $request){ public function select(Request $request)
{
$search = $request->query('search'); $search = $request->query('search');
@ -177,17 +181,16 @@ class HumanResourceController extends Controller
$data['old_password'] = md5($request->old_password); $data['old_password'] = md5($request->old_password);
if ($data['old_password'] !== $result->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); 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); 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); 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'); Artisan::call('sync:integration-human-resources');
} }
} }

Loading…
Cancel
Save