| 1 |  |  | <?php namespace Bantenprov\VueWorkflow\Http\Controllers; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | use App\Http\Controllers\Controller; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | use Illuminate\Http\Request; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Bantenprov\VueWorkflow\Facades\VueWorkflow; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Bantenprov\VueWorkflow\Models\Workflow; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Bantenprov\VueWorkflow\Models\WorkflowType; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Bantenprov\VueWorkflow\Models\Transition; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Validator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Bantenprov\VueWorkflow\Http\Traits\WorkflowTrait; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * The VueWorkflowController class. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * @package Bantenprov\VueWorkflow | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * @author  bantenprov <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | class WorkflowController extends Controller | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     use WorkflowTrait; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     protected $workflowModel; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     protected $workflowTypeModel; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      * WorkflowController constructor. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      * @param Request $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |      * @param Workflow $workflow | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |      * @param WorkflowType $workflowType | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     public function __construct(Request $request, Workflow $workflow, WorkflowType $workflowType){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         $this->workflowModel        = $workflow; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         $this->workflowTypeModel    = $workflowType;  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         //dd($request->path()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      * @param Request $req | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |      * @return \Illuminate\Http\JsonResponse | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     public function index(Request $req) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     {      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |               | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         // $transition = Transition::where('name','propose-to-propose')->where('workflow_id','19')->first(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         // dd($transition->id); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         //dd($this->getRequest($req->input('sort')));   | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         //dd(class_basename($this->workflowTypeModel)); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         //dd(class_basename(get_class($this))); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         //dd(get_declared_classes()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         // foreach (get_declared_classes() as $value) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         //     //Illuminate\Database\Eloquent\Model | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         //     if(get_parent_class($value) == "Illuminate\Database\Eloquent\Model"){ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         //         echo $value."<br>"; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         //     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         //     //echo $value."<br>"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |              | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         // } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         // dd(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         $response = array(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         $param = explode('|',$req->get('sort')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         if($req->get('filter') != ''){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |             $search = "%{$req->get('filter')}%"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |             $response = $this->workflowModel->where('name','like',$search)->orderBy($param[0], $param[1])->paginate(10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         }else{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |             if($req->get('sort') == ''){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |                 $response = $this->workflowModel->paginate(10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |             }else{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |                 $response = $this->workflowModel->orderBy($param[0], $param[1])->paginate(10);      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |             }                 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         return response()->json($response); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |      * @return \Illuminate\Http\JsonResponse | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 84 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  |     public function create() | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  |     {         | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |         $content_type = config('vue-workflow.content_type'); | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |          | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |         return response()->json($content_type); | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |      * @param Request $req | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |      * @return \Illuminate\Http\JsonResponse | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |     public function store(Request $req) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |         // $request['content_id']      = 1; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         // $request['content_type']    = $req->content_type; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |         $request['label']           = $req->label; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         $request['name']            = $req->name; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         $validator = Validator::make($req->all(),[ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |             'label'             => 'required', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |             'name'              => 'required' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 109 |  | View Code Duplication |         if($validator->fails()){ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |             $response['message']    = 'failed transition allready exist !'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |             $response['status']     = false;                | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |         }else{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |             $response['message']    = 'success add new transition'; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |             $response['status']     = true;                 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |         //$this->insertWithWorkflow($this->workflowModel, $request); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |         $this->workflowModel->create($request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |         return response()->json($response); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |      * @param $id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |      * @return \Illuminate\Http\JsonResponse | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |     public function show($id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |         $check = $this->workflowTypeModel->where('workflow_id',$id)->count(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |         if($check > 0){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |             $response = $this->workflowModel->findOrFail($id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |             $response['workflow_type'] = ['label' =>$this->workflowModel->findOrFail($id)->getWorkflowType->workflow_type]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |             $response['content_type'] = ['label' => $this->workflowModel->findOrFail($id)->getWorkflowType->content_type]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |             $response['status'] = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |         }else{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |             $response = $this->workflowModel->findOrFail($id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |             $response['workflow_type'] = '-'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |             $response['content_type'] = '-'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |             $response['status'] = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |         return response()->json($response); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |      * @param $id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |      * @return \Illuminate\Http\JsonResponse | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |      */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 149 |  | View Code Duplication |     public function edit($id) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |     {         | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |                  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |         $response['status']     = true; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |         $response['workflow']   = $this->workflowModel->findOrFail($id); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |         return response()->json($response); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |      * @param $id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |      * @param Request $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |      * @return \Illuminate\Http\JsonResponse | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |     public function update($id, Request $request) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |     {       | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |         $validator = Validator::make($request->all(), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |             'label' => 'required', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |             'name'  => 'required' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |         if($validator->fails()){ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |             $response['status']     = false; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |             $response['message']    = 'failed update '; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |         }else{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |             $response['status']     = true; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |             $response['message']    = 'update success'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |             $this->workflowModel->findOrFail($id)->update($request->all()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |                  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |          | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |         return response()->json($response); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |      * @param Request $req | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |      * @param $id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |      * @return \Illuminate\Http\JsonResponse | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |     public function storeWorkflow(Request $req, $id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |         $workflow['workflow_id']    = $id; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |         $workflow['workflow_type']  = $req->workflow_type; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |         $workflow['content_type']   = $req->content_type; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |         $this->workflowTypeModel->create($workflow); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |         return response()->json(['status' => true, 'message' => 'Success register workflow']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |      * @param $id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |      * @return \Illuminate\Http\JsonResponse | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |      * @throws \Exception | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |     public function destroy($id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |         $state = $this->workflowModel->findOrFail($id)->delete(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |         return response()->json(['status' => true]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 217 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 218 |  |  |  | 
            
                        
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.