예제 #1
0
    if ($result) {
        $response->json(Result::success('', $result));
    } else {
        $response->json(Result::error('RentProcess not found'));
    }
});
$this->respond(['GET', 'POST'], '/edit/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $data = json_decode($request->body(), true);
    $result = RentProcesses::updateRentProcess($id, $data);
    if ($result > 0) {
        $response->json(Result::success('RentProcess Updated.'));
    } elseif ($result === 0) {
        $response->json(Result::success('RentProcess not Updated.'));
    } else {
        $response->json(Result::error('RentProcess not found'));
    }
});
$this->respond(['GET', 'POST'], '/delete/[:id]', function ($request, $response, $service, $app) {
    $id = $request->param('id');
    $result = RentProcesses::deleteRentProcess($id);
    if ($result > 0) {
        $response->json(Result::success('RentProcess Deleted.'));
    } else {
        $response->json(Result::error('RentProcess not Deleted'));
    }
});
$this->respond(['GET', 'POST'], '/get/all', function ($request, $response, $service, $app) {
    $result = RentProcesses::getAllRentProcesses();
    $response->json(Result::success('', $result));
});