app/Http/Controllers/ItemRequestController.php
/*
    * Approve solder to company request by company user
    */
Approve solder to company request by company user
Approve solder to company request by company user
public function companyApproveRequest(Request $request){
        try{
            $companyUser = $request->user();
            if(!$companyUser || !$companyUser->hasRole('company'))
                throw new Exception("You need to logged in as company");
            if( !$request->input('solder_request_id'))
                throw new Exception("Must be need request ID");
            $currentRequest = SolderItemRequest::find( $request->input('solder_request_id'));
            if( !$currentRequest )
                throw new Exception("Sorry didn't find your request data");
            $currentRequest->status = 2;
            $currentRequest->save();
            $currentRequest->soldier_device_id= User::find($currentRequest->user_id)->device_id;
            $actionItem = SolderKits::find( $currentRequest->solder_kit_id );
            $actionItem->status = 2; 
            $actionItem->save();
            return ['success'=>true ,'message'=>'Approve successful!','data'=>$currentRequest];
        }catch (Exception $e){
            return ['success'=>false, 'message'=>$e->getMessage()];
        }
    }
public function companyApproveRequest ( Request $ request ) { try { $ companyUser = $ request -> user ( ) ; if ( ! $ companyUser || ! $ companyUser -> hasRole ( 'company' ) ) throw new Exception ( " You need to logged in as company " ) ; if ( ! $ request -> input ( 'solder_request_id' ) ) throw new Exception ( " Must be need request ID " ) ; $ currentRequest = SolderItemRequest :: find ( $ request -> input ( 'solder_request_id' ) ) ; if ( ! $ currentRequest ) throw new Exception ( " Sorry didn't find your request data " ) ; $ currentRequest -> status = 2 ; $ currentRequest -> save ( ) ; $ currentRequest -> soldier_device_id = User :: find ( $ currentRequest -> user_id ) -> device_id ; $ actionItem = SolderKits :: find ( $ currentRequest -> solder_kit_id ) ; $ actionItem -> status = 2 ; $ actionItem -> save ( ) ; return [ 'success' => true , 'message' => 'Approve successful!' , 'data' => $ currentRequest ] ; } catch ( Exception $ e ) { return [ 'success' => false , 'message' => $ e -> getMessage ( ) ] ; } }
Approve solder to company request by company user
Approve solder to company request by company user
// cancel and re-usable