app/Http/Controllers/ItemRequestController.php
/*
    * Soldier can cancel their request
    * If soldier cancel the request then delete the requested id
    */
Soldier can cancel their request
If soldier cancel the request then delete the requested id
Soldier can cancel their request If soldier cancel the request then delete the requested id
public function soldierCancelRequest(Request $request){
       try{
           $soldier = $request->user();
           if(!$soldier || !$soldier->hasRole('solder'))
               throw new Exception("You need to logged in as soldier");
           if( !$request->input('solider_request_id'))
               throw new Exception("Must be need request ID");
           $currentRequest = SolderItemRequest::find( $request->input('soldier_request_id'));
           if( !$currentRequest )
               throw new Exception("Sorry didn't find your request data");
           $actionItem = SolderKits::find( $currentRequest->solder_kit_id );
           $actionItem->status = 1; 
           $actionItem->save();
           $currentRequest->delete();
           return ['success'=>true ,'message'=>'Item request cancel!', 'data'=>$actionItem];
       }catch (Exception $e){
           return ['success'=>false, 'message'=>$e->getMessage()];
       }
   }
public function soldierCancelRequest ( Request $ request ) { try { $ soldier = $ request -> user ( ) ; if ( ! $ soldier || ! $ soldier -> hasRole ( 'solder' ) ) throw new Exception ( " You need to logged in as soldier " ) ; if ( ! $ request -> input ( 'solider_request_id' ) ) throw new Exception ( " Must be need request ID " ) ; $ currentRequest = SolderItemRequest :: find ( $ request -> input ( 'soldier_request_id' ) ) ; if ( ! $ currentRequest ) throw new Exception ( " Sorry didn't find your request data " ) ; $ actionItem = SolderKits :: find ( $ currentRequest -> solder_kit_id ) ; $ actionItem -> status = 1 ; $ actionItem -> save ( ) ; $ currentRequest -> delete ( ) ; return [ 'success' => true , 'message' => 'Item request cancel!' , 'data' => $ actionItem ] ; } catch ( Exception $ e ) { return [ 'success' => false , 'message' => $ e -> getMessage ( ) ] ; } }
Soldier can cancel their request
 If soldier cancel the request then delete the requested id
Soldier can cancel their request If soldier cancel the request then delete the requested id
// cancel and re-usable