| 1 |  |  | <?php
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Bantenprov\DashboardEpormas\Http\Controllers;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use App\Http\Controllers\Controller;
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Illuminate\Http\Request;
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Illuminate\Support\Facades\DB;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Illuminate\Support\Facades\Input;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Bantenprov\DashboardEpormas\Models\EpormasCategory;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Validator, Image, Session, File, Response, Redirect, Exception;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | 
 | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 12 |  | View Code Duplication | class EpormasCategoryController extends Controller
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |   /**
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |    * Display a listing of the resource.
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |    *
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |    * @return Response
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |    */
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |   public function index()
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |   {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |       try {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |           $error = false;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |           $statusCode = 200;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |           $title = 'Success';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |           $type = 'success';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |           $message = 'Success';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |           $result = EpormasCategory::all();
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |       } catch (Exception $e) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |           $error = true;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |           $statusCode = 404;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |           $title = 'Error';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |           $type = 'error';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |           $message = 'Error';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |           $result = 'Not Found';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |       } finally {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |           return Response::json(array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |             'error' => $error,
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |             'status' => $statusCode,
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |             'title' => $title,
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |             'type' => $type,
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |             'message' => $message,
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |             'result' => $result
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |           ));
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |       }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |   }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |   /**
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |    * Show the form for creating a new resource.
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |    *
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |    * @return Response
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |    */
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |   public function create()
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |   {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |   }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |   /**
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |    * Store a newly created resource in storage.
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |    *
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |    * @return Response
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |    */
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |   public function store(Request $request, $version='')
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |   {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         $path = \Request::path();
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         $explode = explode('/', $path);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         $from = 'form';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         if(in_array('api',$explode)){
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |           $from = 'api';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |         $via = $from;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |         if($version != '' && $version != 'store'){
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |           $via .= '-'.$version;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |       	$rules = [
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |             'name' => 'required'
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         ];
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         $validator = Validator::make($request->all(), $rules);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |         if ($validator->fails()) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |           return response()->json([
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |               'title' => 'Error',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |               'type'  => 'error',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |               'message' => $validator->errors()->all()
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |           ]);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |         $data = EpormasCategory::whereNull('deleted_at')
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |                         ->where('name', $request->name)
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |                         ->count();
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |         if($data > 0){
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |           return response()->json([
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |               'title' => 'Error',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |               'type'  => 'error',
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |               'message' => 'Data has already been taken.'
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |           ]);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         try {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |             $error = false;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |             $statusCode = 200;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |             $title = 'Success';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |             $type = 'success';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |             $message = 'Data created successfully';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |             $result = EpormasCategory::create([
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |                 'name' => $request->name
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |             ]);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |         } catch (Exception $e) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |             $error = true;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |             $statusCode = 404;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |             $title = 'Error';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |             $type = 'error';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |             $message = 'Error';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |             $result = 'Not Found';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |         } finally {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |             return Response::json(array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |               'error' => $error,
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |               'status' => $statusCode,
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |               'title' => $title,
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |               'type' => $type,
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |               'message' => $message,
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |               'result' => $result
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |             ));
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |   }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |   /**
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |    * Display the specified resource.
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |    *
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |    * @param  int  $id
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |    * @return Response
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |    */
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |   public function show($version='', $id)
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |   {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |         try {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |             $error = false;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |             $statusCode = 200;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |             $title = 'Success';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |             $type = 'success';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |             $message = 'Success';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |             $result = EpormasCategory::findOrFail($id);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |         } catch (Exception $e) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |             $error = true;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |             $statusCode = 404;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |             $title = 'Error';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |             $type = 'error';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |             $message = 'Error';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |             $result = 'Not Found';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |         } finally {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |             return Response::json(array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |               'error' => $error,
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |               'status' => $statusCode,
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |               'title' => $title,
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |               'type' => $type,
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |               'message' => $message,
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |               'result' => $result
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |             ));
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |   }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |   /**
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |    * Show the form for editing the specified resource.
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |    *
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |    * @param  int  $id
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |    * @return Response
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |    */
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |   public function edit($id)
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |   {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |         try {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |             $error = false;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |             $statusCode = 200;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |             $title = 'Success';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |             $type = 'success';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |             $message = 'Success';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |             $result = EpormasCategory::findOrFail($id);
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |         } catch (Exception $e) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |             $error = true;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |             $statusCode = 404;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |             $title = 'Error';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |             $type = 'error';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |             $message = 'Error';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |             $result = 'Not Found';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |         } finally {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |             return Response::json(array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |               'error' => $error,
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |               'status' => $statusCode,
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |               'title' => $title,
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |               'type' => $type,
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |               'message' => $message,
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |               'result' => $result
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |             ));
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |   }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |   /**
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |    * Update the specified resource in storage.
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |    *
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |    * @param  int  $id
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |    * @return Response
 | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 203 |  |  |    */
 | 
            
                                                                        
                            
            
                                    
            
            
                | 204 |  |  |   public function update(Request $request, $version='', $id)
 | 
            
                                                                        
                            
            
                                    
            
            
                | 205 |  |  |   {
 | 
            
                                                                        
                            
            
                                    
            
            
                | 206 |  |  |         $result = EpormasCategory::find($id);
 | 
            
                                                                        
                            
            
                                    
            
            
                | 207 |  |  | 
 | 
            
                                                                        
                            
            
                                    
            
            
                | 208 |  |  |         $rules = [
 | 
            
                                                                        
                            
            
                                    
            
            
                | 209 |  |  |             'name' => 'required'
 | 
            
                                                                        
                            
            
                                    
            
            
                | 210 |  |  |         ];
 | 
            
                                                                        
                            
            
                                    
            
            
                | 211 |  |  | 
 | 
            
                                                                        
                            
            
                                    
            
            
                | 212 |  |  |         $validator = Validator::make($request->all(), $rules);
 | 
            
                                                                        
                            
            
                                    
            
            
                | 213 |  |  |         if ($validator->fails()) {
 | 
            
                                                                        
                            
            
                                    
            
            
                | 214 |  |  |           return response()->json([
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 215 |  |  |               'title' => 'Error',
 | 
            
                                                                        
                            
            
                                    
            
            
                | 216 |  |  |               'type'  => 'error',
 | 
            
                                                                        
                            
            
                                    
            
            
                | 217 |  |  |               'message' => $validator->errors()->all()
 | 
            
                                                                        
                            
            
                                    
            
            
                | 218 |  |  |           ]);
 | 
            
                                                                        
                            
            
                                    
            
            
                | 219 |  |  |         }
 | 
            
                                                                        
                            
            
                                    
            
            
                | 220 |  |  | 
 | 
            
                                                                        
                            
            
                                    
            
            
                | 221 |  |  |         if($request->name != $result->name){
 | 
            
                                                                        
                            
            
                                    
            
            
                | 222 |  |  |           $data = EpormasCategory::whereNull('deleted_at')
 | 
            
                                                                        
                            
            
                                    
            
            
                | 223 |  |  |                           ->where('name', $request->name)
 | 
            
                                                                        
                            
            
                                    
            
            
                | 224 |  |  |                           ->count();
 | 
            
                                                                        
                            
            
                                    
            
            
                | 225 |  |  |           if($data > 0){
 | 
            
                                                                        
                            
            
                                    
            
            
                | 226 |  |  |             return response()->json([
 | 
            
                                                                        
                            
            
                                    
            
            
                | 227 |  |  |                 'title' => 'Error',
 | 
            
                                                                        
                            
            
                                    
            
            
                | 228 |  |  |                 'type'  => 'error',
 | 
            
                                                                        
                            
            
                                    
            
            
                | 229 |  |  |                 'message' => 'Data has already been taken.'
 | 
            
                                                                        
                            
            
                                    
            
            
                | 230 |  |  |             ]);
 | 
            
                                                                        
                            
            
                                    
            
            
                | 231 |  |  |           }
 | 
            
                                                                        
                            
            
                                    
            
            
                | 232 |  |  |         }
 | 
            
                                                                        
                            
            
                                    
            
            
                | 233 |  |  | 
 | 
            
                                                                        
                            
            
                                    
            
            
                | 234 |  |  |         $path = \Request::path();
 | 
            
                                                                        
                            
            
                                    
            
            
                | 235 |  |  |         $explode = explode('/', $path);
 | 
            
                                                                        
                            
            
                                    
            
            
                | 236 |  |  | 
 | 
            
                                                                        
                            
            
                                    
            
            
                | 237 |  |  |         $from = 'form';
 | 
            
                                                                        
                            
            
                                    
            
            
                | 238 |  |  |         if(in_array('api',$explode)){
 | 
            
                                                                        
                            
            
                                    
            
            
                | 239 |  |  |           $from = 'api';
 | 
            
                                                                        
                            
            
                                    
            
            
                | 240 |  |  |         }
 | 
            
                                                                        
                            
            
                                    
            
            
                | 241 |  |  | 
 | 
            
                                                                        
                            
            
                                    
            
            
                | 242 |  |  |         $via = $from;
 | 
            
                                                                        
                            
            
                                    
            
            
                | 243 |  |  |         if($version != '' && $version != 'update'){
 | 
            
                                                                        
                            
            
                                    
            
            
                | 244 |  |  |           $via .= '-'.$version;
 | 
            
                                                                        
                            
            
                                    
            
            
                | 245 |  |  |         }
 | 
            
                                                                        
                            
            
                                    
            
            
                | 246 |  |  | 
 | 
            
                                                                        
                            
            
                                    
            
            
                | 247 |  |  |         try {
 | 
            
                                                                        
                            
            
                                    
            
            
                | 248 |  |  |             $error = false;
 | 
            
                                                                        
                            
            
                                    
            
            
                | 249 |  |  |             $statusCode = 200;
 | 
            
                                                                        
                            
            
                                    
            
            
                | 250 |  |  |             $title = 'Success';
 | 
            
                                                                        
                            
            
                                    
            
            
                | 251 |  |  |             $type = 'success';
 | 
            
                                                                        
                            
            
                                    
            
            
                | 252 |  |  |             $message = 'Data updated successfully';
 | 
            
                                                                        
                            
            
                                    
            
            
                | 253 |  |  |             $result->update([
 | 
            
                                                                        
                            
            
                                    
            
            
                | 254 |  |  |                 'name' => $request->name
 | 
            
                                                                        
                            
            
                                    
            
            
                | 255 |  |  |             ]);
 | 
            
                                                                        
                            
            
                                    
            
            
                | 256 |  |  |         } catch (Exception $e) {
 | 
            
                                                                        
                            
            
                                    
            
            
                | 257 |  |  |             $error = true;
 | 
            
                                                                        
                            
            
                                    
            
            
                | 258 |  |  |             $statusCode = 404;
 | 
            
                                                                        
                            
            
                                    
            
            
                | 259 |  |  |             $title = 'Error';
 | 
            
                                                                        
                            
            
                                    
            
            
                | 260 |  |  |             $type = 'error';
 | 
            
                                                                        
                            
            
                                    
            
            
                | 261 |  |  |             $message = 'Error';
 | 
            
                                                                        
                            
            
                                    
            
            
                | 262 |  |  |             $result = 'Not Found';
 | 
            
                                                                        
                            
            
                                    
            
            
                | 263 |  |  |         } finally {
 | 
            
                                                                        
                            
            
                                    
            
            
                | 264 |  |  |             return Response::json(array(
 | 
            
                                                                        
                            
            
                                    
            
            
                | 265 |  |  |               'error' => $error,
 | 
            
                                                                        
                            
            
                                    
            
            
                | 266 |  |  |               'status' => $statusCode,
 | 
            
                                                                        
                            
            
                                    
            
            
                | 267 |  |  |               'title' => $title,
 | 
            
                                                                        
                            
            
                                    
            
            
                | 268 |  |  |               'type' => $type,
 | 
            
                                                                        
                            
            
                                    
            
            
                | 269 |  |  |               'message' => $message,
 | 
            
                                                                        
                            
            
                                    
            
            
                | 270 |  |  |               'result' => $result
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |             ));
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |         }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |   }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |   /**
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |    * Remove the specified resource from storage.
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |    *
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |    * @param  int  $id
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |    * @return Response
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |    */
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |   public function destroy($id)
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |   {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |       try {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |           EpormasCategory::find($id)->delete();
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |           $error = false;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |           $statusCode = 200;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |           $title = 'Success';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |           $type = 'success';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |           $message = 'Data deleted successfully';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |       } catch (Exception $e) {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |           $error = true;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |           $statusCode = 404;
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |           $title = 'Error';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |           $type = 'error';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |           $message = 'Error';
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |       } finally {
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |           return Response::json(array(
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |             'error' => $error,
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |             'status' => $statusCode,
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |             'title' => $title,
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |             'type' => $type,
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |             'message' => $message
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |           ));
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |       }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |   }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  | 
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  | }
 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  | 
 | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 309 |  |  | ?>
 | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                        
            
                                    
            
            
                | 310 |  |  |  | 
            
                        
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths