Add delete method to WarrantyController. #250
This commit is contained in:
parent
2f8eab2236
commit
cf89311e17
4 changed files with 30 additions and 1 deletions
|
|
@ -80,6 +80,10 @@ class TestAPICommand extends Command
|
||||||
// plate warranty
|
// plate warranty
|
||||||
$api->get('/capi/plates/' . $plate_num . '/warranties');
|
$api->get('/capi/plates/' . $plate_num . '/warranties');
|
||||||
|
|
||||||
|
// warranty delete
|
||||||
|
$id = 86811;
|
||||||
|
$api->post('/capi/warranties/' . $id . '/delete');
|
||||||
|
|
||||||
// battery
|
// battery
|
||||||
$api->get('/capi/battery_brands');
|
$api->get('/capi/battery_brands');
|
||||||
$api->get('/capi/battery_sizes');
|
$api->get('/capi/battery_sizes');
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ access_keys:
|
||||||
label: Claim
|
label: Claim
|
||||||
- id: warranty.cancel
|
- id: warranty.cancel
|
||||||
label: Cancel
|
label: Cancel
|
||||||
|
- id: warranty.delete
|
||||||
|
label: Delete
|
||||||
- id: batterybrand
|
- id: batterybrand
|
||||||
label: Battery Brand Access
|
label: Battery Brand Access
|
||||||
acls:
|
acls:
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,12 @@ capi_warranty_cancel:
|
||||||
controller: App\Controller\CAPI\WarrantyController::cancel
|
controller: App\Controller\CAPI\WarrantyController::cancel
|
||||||
methods: [GET]
|
methods: [GET]
|
||||||
|
|
||||||
|
# delete warranty
|
||||||
|
capi_warranty_delete:
|
||||||
|
path: /capi/warranties/{id}/delete
|
||||||
|
controller: App\Controller\CAPI\WarrantyController::delete
|
||||||
|
methods: [POST]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# customer vehicle api
|
# customer vehicle api
|
||||||
|
|
|
||||||
|
|
@ -339,6 +339,23 @@ class WarrantyController extends APIController
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
return new APIResponse(true, 'Warranty cancelled successfully.');
|
return new APIResponse(true, 'Warranty cancelled successfully.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete(EntityManagerInterface $em, $id)
|
||||||
|
{
|
||||||
|
$this->denyAccessUnlessGranted('warranty.delete', null, 'No access.');
|
||||||
|
|
||||||
|
// find warranty
|
||||||
|
$warr = $em->getRepository(Warranty::class)->find($id);
|
||||||
|
if ($warr == null)
|
||||||
|
{
|
||||||
|
return new APIResponse(false, 'No warranty found with that id.', null, 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete the warranty
|
||||||
|
$em->remove($warr);
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
|
return new APIResponse(true, 'Warranty deleted successfully.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue