Add Json Response Helper
This commit is contained in:
@@ -61,10 +61,7 @@ class DoctorController extends Controller
|
||||
|
||||
$doctors = $doctors->paginate($limit);
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Sukses mengambil data Dokter',
|
||||
'doctors' => Helper::paginateResources(PractitionerRoleToDoctorResource::collection($doctors))
|
||||
]);
|
||||
return Helper::makeJsonResponse(Helper::paginateResources(PractitionerRoleToDoctorResource::collection($doctors)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -147,4 +147,13 @@ class Helper
|
||||
{
|
||||
return "Rp. " . number_format($price, 0, ',', '.');
|
||||
}
|
||||
|
||||
public static function makeJsonResponse($data, $statusCode = 200, $message = "Data berhasil diambil")
|
||||
{
|
||||
return response()->json([
|
||||
'statusCode' => $statusCode,
|
||||
'message' => $message,
|
||||
'data' => $data
|
||||
], $statusCode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,4 +79,9 @@ class User extends Authenticatable
|
||||
{
|
||||
return $this->belongsTo(Person::class, 'person_id');
|
||||
}
|
||||
|
||||
public function ownedPersons()
|
||||
{
|
||||
return $this->hasMany(Person::class, 'owner_user_id');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user