| Total Complexity | 45 |
| Total Lines | 567 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Complex classes like ProductController often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ProductController, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 32 | class ProductController extends BaseProductController |
||
| 33 | { |
||
| 34 | use ChunkUpload; |
||
| 35 | |||
| 36 | public $product; |
||
| 37 | public $price; |
||
| 38 | public $type; |
||
| 39 | public $subscription; |
||
| 40 | public $currency; |
||
| 41 | public $group; |
||
| 42 | public $plan; |
||
| 43 | public $tax; |
||
| 44 | public $tax_relation; |
||
| 45 | public $tax_class; |
||
| 46 | public $product_upload; |
||
| 47 | |||
| 48 | public function __construct() |
||
| 49 | { |
||
| 50 | $this->middleware('auth'); |
||
| 51 | $this->middleware('admin', ['except' => ['adminDownload', 'userDownload']]); |
||
| 52 | |||
| 53 | $product = new Product(); |
||
| 54 | $this->product = $product; |
||
| 55 | |||
| 56 | $price = new Price(); |
||
| 57 | $this->price = $price; |
||
| 58 | |||
| 59 | $type = new LicenseType(); |
||
| 60 | $this->type = $type; |
||
| 61 | |||
| 62 | $subscription = new Subscription(); |
||
| 63 | $this->subscription = $subscription; |
||
| 64 | |||
| 65 | $currency = new Currency(); |
||
| 66 | $this->currency = $currency; |
||
| 67 | |||
| 68 | $group = new ProductGroup(); |
||
| 69 | $this->group = $group; |
||
| 70 | |||
| 71 | $plan = new Plan(); |
||
| 72 | $this->plan = $plan; |
||
| 73 | |||
| 74 | $tax = new Tax(); |
||
| 75 | $this->tax = $tax; |
||
| 76 | |||
| 77 | $period = new Period(); |
||
| 78 | $this->period = $period; |
||
| 79 | |||
| 80 | $tax_relation = new TaxProductRelation(); |
||
| 81 | $this->tax_relation = $tax_relation; |
||
| 82 | |||
| 83 | $tax_class = new TaxClass(); |
||
| 84 | $this->tax_class = $tax_class; |
||
| 85 | |||
| 86 | $product_upload = new ProductUpload(); |
||
| 87 | $this->product_upload = $product_upload; |
||
| 88 | |||
| 89 | $license = new LicenseController(); |
||
| 90 | $this->licensing = $license; |
||
| 91 | } |
||
| 92 | |||
| 93 | /** |
||
| 94 | * Display a listing of the resource. |
||
| 95 | * |
||
| 96 | * @return \Response |
||
| 97 | */ |
||
| 98 | public function index() |
||
| 99 | { |
||
| 100 | try { |
||
| 101 | return view('themes.default1.product.product.index'); |
||
| 102 | } catch (\Exception $e) { |
||
| 103 | Bugsnag::notifyException($e); |
||
| 104 | |||
| 105 | return redirect('/')->with('fails', $e->getMessage()); |
||
| 106 | } |
||
| 107 | } |
||
| 108 | |||
| 109 | /** |
||
| 110 | * Display a listing of the resource. |
||
| 111 | * |
||
| 112 | * @return \Response |
||
| 113 | */ |
||
| 114 | public function getProducts() |
||
| 115 | { |
||
| 116 | try { |
||
| 117 | $new_product = Product::select('id', 'name', 'type', 'image', 'group', 'image')->get(); |
||
| 118 | |||
| 119 | return\ DataTables::of($new_product) |
||
| 120 | |||
| 121 | ->addColumn('checkbox', function ($model) { |
||
| 122 | return "<input type='checkbox' class='product_checkbox' |
||
| 123 | value=".$model->id.' name=select[] id=check>'; |
||
| 124 | }) |
||
| 125 | ->addColumn('name', function ($model) { |
||
| 126 | return ucfirst($model->name); |
||
| 127 | }) |
||
| 128 | ->addColumn('image', function ($model) { |
||
| 129 | // return $model->image; |
||
| 130 | return "<img src= '$model->image' + height=\"80\"/>"; |
||
| 131 | }) |
||
| 132 | ->addColumn('type', function ($model) { |
||
| 133 | if ($this->type->where('id', $model->type)->first()) { |
||
| 134 | return $this->type->where('id', $model->type)->first()->name; |
||
| 135 | } else { |
||
| 136 | return 'Not available'; |
||
| 137 | } |
||
| 138 | }) |
||
| 139 | ->addColumn('group', function ($model) { |
||
| 140 | if ($this->group->where('id', $model->group)->first()) { |
||
| 141 | return $this->group->where('id', $model->group)->first()->name; |
||
| 142 | } else { |
||
| 143 | return 'Not available'; |
||
| 144 | } |
||
| 145 | }) |
||
| 146 | |||
| 147 | ->addColumn('Action', function ($model) { |
||
| 148 | $permissions = LicensePermissionsController::getPermissionsForProduct($model->id); |
||
| 149 | $url = ''; |
||
| 150 | if ($permissions['downloadPermission'] == 1) { |
||
| 151 | $url = '<a href='.url('product/download/'.$model->id). |
||
| 152 | " class='btn btn-sm btn-secondary btn-xs'".tooltip('Download')."<i class='fas fa-cloud-download-alt' |
||
| 153 | style='color:white;'> </i></a>"; |
||
| 154 | } |
||
| 155 | |||
| 156 | return '<p><a href='.url('products/'.$model->id.'/edit'). |
||
| 157 | " class='btn btn-sm btn-secondary btn-xs'".tooltip('Edit')."<i class='fa fa-edit' |
||
| 158 | style='color:white;'> </i></a> $url</p>"; |
||
| 159 | }) |
||
| 160 | |||
| 161 | ->rawColumns(['checkbox', 'name', 'image', 'type', 'group', 'Action']) |
||
| 162 | ->make(true); |
||
| 163 | } catch (\Exception $e) { |
||
| 164 | Bugsnag::notifyException($e); |
||
| 165 | |||
| 166 | return redirect()->back()->with('fails', $e->getMessage()); |
||
| 167 | } |
||
| 168 | } |
||
| 169 | |||
| 170 | // Save file Info in Modal popup |
||
| 171 | public function save(Request $request) |
||
| 172 | { |
||
| 173 | $this->validate( |
||
| 174 | $request, |
||
| 175 | [ |
||
| 176 | 'producttitle' => 'required', |
||
| 177 | 'version' => 'required', |
||
| 178 | 'filename' => 'required', |
||
| 179 | ], |
||
| 180 | ['filename.required' => 'Please Uplaod A file', |
||
| 181 | ] |
||
| 182 | ); |
||
| 183 | |||
| 184 | try { |
||
| 185 | $product_id = Product::where('name', $request->input('productname'))->select('id')->first(); |
||
| 186 | |||
| 187 | $this->product_upload->product_id = $product_id->id; |
||
| 188 | $this->product_upload->title = $request->input('producttitle'); |
||
| 189 | $this->product_upload->description = $request->input('description'); |
||
| 190 | $this->product_upload->version = $request->input('version'); |
||
| 191 | $this->product_upload->file = $request->input('filename'); |
||
| 192 | $this->product_upload->save(); |
||
| 193 | $this->product->where('id', $product_id->id)->update(['version'=>$request->input('version')]); |
||
| 194 | $autoUpdateStatus = StatusSetting::pluck('update_settings')->first(); |
||
| 195 | if ($autoUpdateStatus == 1) { //If License Setting Status is on,Add Product to the License Manager |
||
| 196 | $updateClassObj = new \App\Http\Controllers\AutoUpdate\AutoUpdateController(); |
||
| 197 | $addProductToAutoUpdate = $updateClassObj->addNewVersion($product_id->id, $request->input('version'), $request->input('filename'), '1'); |
||
|
|
|||
| 198 | } |
||
| 199 | $response = ['success'=>'true', 'message'=>'Product Uploaded Successfully']; |
||
| 200 | |||
| 201 | return $response; |
||
| 202 | } catch (\Exception $e) { |
||
| 203 | app('log')->error($e->getMessage()); |
||
| 204 | Bugsnag::notifyException($e); |
||
| 205 | $message = [$e->getMessage()]; |
||
| 206 | $response = ['success'=>'false', 'message'=>$message]; |
||
| 207 | |||
| 208 | return response()->json(compact('response'), 500); |
||
| 209 | } |
||
| 210 | } |
||
| 211 | |||
| 212 | /** |
||
| 213 | * Show the form for creating a new resource. |
||
| 214 | * |
||
| 215 | * @return \Response |
||
| 216 | */ |
||
| 217 | public function create() |
||
| 218 | { |
||
| 219 | try { |
||
| 220 | /* |
||
| 221 | * server url |
||
| 222 | */ |
||
| 223 | $url = url('/'); |
||
| 224 | $id = $this->product->orderBy('id', 'desc')->first(); |
||
| 225 | $i = $id ? $id->id + 1 : 1; |
||
| 226 | $cartUrl = $url.'/pricing?id='.$i; |
||
| 227 | $type = $this->type->pluck('name', 'id')->toArray(); |
||
| 228 | $subscription = $this->plan->pluck('name', 'id')->toArray(); |
||
| 229 | $currency = $this->currency->where('status', 1)->pluck('name', 'code')->toArray(); |
||
| 230 | $group = $this->group->pluck('name', 'id')->toArray(); |
||
| 231 | $products = $this->product->pluck('name', 'id')->toArray(); |
||
| 232 | $periods = $this->period->pluck('name', 'days')->toArray(); |
||
| 233 | $taxes = $this->tax_class->pluck('name', 'id')->toArray(); |
||
| 234 | |||
| 235 | return view( |
||
| 236 | 'themes.default1.product.product.create', |
||
| 237 | compact( |
||
| 238 | 'subscription', |
||
| 239 | 'type', |
||
| 240 | 'periods', |
||
| 241 | 'currency', |
||
| 242 | 'group', |
||
| 243 | 'cartUrl', |
||
| 244 | 'products', |
||
| 245 | 'taxes' |
||
| 246 | ) |
||
| 247 | ); |
||
| 248 | } catch (\Exception $e) { |
||
| 249 | Bugsnag::notifyException($e); |
||
| 250 | |||
| 251 | return redirect()->back()->with('fails', $e->getMessage()); |
||
| 252 | } |
||
| 253 | } |
||
| 254 | |||
| 255 | /** |
||
| 256 | * Store a newly created resource in storage. |
||
| 257 | * |
||
| 258 | * @return \Response |
||
| 259 | */ |
||
| 260 | public function store(Request $request) |
||
| 261 | { |
||
| 262 | $input = $request->all(); |
||
| 263 | $v = \Validator::make($input, [ |
||
| 264 | 'name' => 'required|unique:products,name', |
||
| 265 | 'type' => 'required', |
||
| 266 | 'description'=> 'required', |
||
| 267 | 'category' => 'required', |
||
| 268 | 'image' => 'sometimes | mimes:jpeg,jpg,png,gif | max:1000', |
||
| 269 | 'product_sku'=> 'required|unique:products,product_sku', |
||
| 270 | 'group' => 'required', |
||
| 271 | 'show_agent' => 'required', |
||
| 272 | // 'version' => 'required', |
||
| 273 | ], [ |
||
| 274 | 'show_agent.required' => 'Select you Cart Page Preference', |
||
| 275 | ]); |
||
| 276 | |||
| 277 | if ($v->fails()) { |
||
| 278 | // $currency = $input['currency']; |
||
| 279 | |||
| 280 | return redirect()->back() |
||
| 281 | ->withErrors($v) |
||
| 282 | ->withInput($request->input()); |
||
| 283 | } |
||
| 284 | |||
| 285 | try { |
||
| 286 | $licenseStatus = StatusSetting::pluck('license_status')->first(); |
||
| 287 | if ($licenseStatus) { //If License Setting Status is on,Add Product to the License Manager |
||
| 288 | $addProductToLicensing = $this->licensing->addNewProduct($input['name'], $input['product_sku']); |
||
| 289 | } |
||
| 290 | $updateCont = new \App\Http\Controllers\AutoUpdate\AutoUpdateController(); |
||
| 291 | $addProductToLicensing = $updateCont->addNewProductToAUS($input['name'], $input['product_sku']); |
||
| 292 | if ($request->hasFile('image')) { |
||
| 293 | $image = $request->file('image')->getClientOriginalName(); |
||
| 294 | $imagedestinationPath = 'common/images'; |
||
| 295 | $request->file('image')->move($imagedestinationPath, $image); |
||
| 296 | $this->product->image = $image; |
||
| 297 | } |
||
| 298 | $can_modify_agent = $request->input('can_modify_agent'); |
||
| 299 | $can_modify_quantity = $request->input('can_modify_quantity'); |
||
| 300 | $this->saveCartValues($input, $can_modify_agent, $can_modify_quantity); |
||
| 301 | $this->product->fill($request->except('image', 'file'))->save(); |
||
| 302 | $taxes = $request->input('tax'); |
||
| 303 | if ($taxes) { |
||
| 304 | foreach ($taxes as $key => $value) { |
||
| 305 | $newtax = new TaxProductRelation(); |
||
| 306 | $newtax->product_id = $this->product->id; |
||
| 307 | $newtax->tax_class_id = $value; |
||
| 308 | $newtax->save(); |
||
| 309 | } |
||
| 310 | } |
||
| 311 | |||
| 312 | return redirect()->back()->with('success', \Lang::get('message.saved-successfully')); |
||
| 313 | } catch (\Exception $e) { |
||
| 314 | app('log')->error($e->getMessage()); |
||
| 315 | Bugsnag::notifyException($e); |
||
| 316 | |||
| 317 | return redirect()->back()->with('fails', $e->getMessage()); |
||
| 318 | } |
||
| 319 | } |
||
| 320 | |||
| 321 | /** |
||
| 322 | * Show the form for editing the specified resource. |
||
| 323 | * |
||
| 324 | * @param int $id |
||
| 325 | * |
||
| 326 | * @return \Response |
||
| 327 | */ |
||
| 328 | public function edit($id) |
||
| 329 | { |
||
| 330 | try { |
||
| 331 | $type = $this->type->pluck('name', 'id')->toArray(); |
||
| 332 | |||
| 333 | $subscription = $this->plan->pluck('name', 'id')->toArray(); |
||
| 334 | $currency = $this->currency->pluck('name', 'code')->toArray(); |
||
| 335 | $group = $this->group->pluck('name', 'id')->toArray(); |
||
| 336 | $products = $this->product->pluck('name', 'id')->toArray(); |
||
| 337 | $checkowner = Product::where('id', $id)->value('github_owner'); |
||
| 338 | $periods = $this->period->pluck('name', 'days')->toArray(); |
||
| 339 | // $url = $this->GetMyUrl(); |
||
| 340 | $url = url('/'); |
||
| 341 | $cartUrl = $url.'/cart?id='.$id; |
||
| 342 | $product = $this->product->where('id', $id)->first(); |
||
| 343 | $selectedGroup = ProductGroup:: where('id', $product->group)->pluck('name')->toArray(); |
||
| 344 | $taxes = $this->tax_class->pluck('name', 'id')->toArray(); |
||
| 345 | $selectedCategory = \App\Model\Product\ProductCategory:: |
||
| 346 | where('category_name', $product->category)->pluck('category_name')->toArray(); |
||
| 347 | $taxes = $this->tax_class->with('tax:tax_classes_id,id,name')->get()->toArray(); |
||
| 348 | $saved_taxes = $this->tax_relation->where('product_id', $id)->get(); |
||
| 349 | $savedTaxes = $this->tax_relation->where('product_id', $id)->pluck('tax_class_id')->toArray(); |
||
| 350 | $showagent = $product->show_agent; |
||
| 351 | $showProductQuantity = $product->show_product_quantity; |
||
| 352 | $canModifyAgent = $product->can_modify_agent; |
||
| 353 | $canModifyQuantity = $product->can_modify_quantity; |
||
| 354 | $githubStatus = StatusSetting::pluck('github_status')->first(); |
||
| 355 | |||
| 356 | return view( |
||
| 357 | 'themes.default1.product.product.edit', |
||
| 358 | compact( |
||
| 359 | 'product', |
||
| 360 | 'periods', |
||
| 361 | 'type', |
||
| 362 | 'subscription', |
||
| 363 | 'currency', |
||
| 364 | 'group', |
||
| 365 | 'cartUrl', |
||
| 366 | 'products', |
||
| 367 | 'taxes', |
||
| 368 | 'saved_taxes', |
||
| 369 | 'savedTaxes', |
||
| 370 | 'selectedCategory', |
||
| 371 | 'selectedGroup', |
||
| 372 | 'showagent', |
||
| 373 | 'showProductQuantity', |
||
| 374 | 'canModifyAgent', |
||
| 375 | 'canModifyQuantity', |
||
| 376 | 'checkowner', |
||
| 377 | 'githubStatus' |
||
| 378 | ) |
||
| 379 | ); |
||
| 380 | } catch (\Exception $e) { |
||
| 381 | Bugsnag::notifyException($e); |
||
| 382 | |||
| 383 | return redirect()->back()->with('fails', $e->getMessage()); |
||
| 384 | } |
||
| 385 | } |
||
| 386 | |||
| 387 | /** |
||
| 388 | * Update the specified resource in storage. |
||
| 389 | * |
||
| 390 | * @param int $id |
||
| 391 | * |
||
| 392 | * @return \Response |
||
| 393 | */ |
||
| 394 | public function update($id, Request $request) |
||
| 395 | { |
||
| 396 | $input = $request->all(); |
||
| 397 | $v = \Validator::make($input, [ |
||
| 398 | 'name' => 'required', |
||
| 399 | 'type' => 'required', |
||
| 400 | 'description'=> 'required', |
||
| 401 | 'image' => 'sometimes | mimes:jpeg,jpg,png,gif | max:1000', |
||
| 402 | 'product_sku'=> 'required', |
||
| 403 | 'group' => 'required', |
||
| 404 | ]); |
||
| 405 | |||
| 406 | if ($v->fails()) { |
||
| 407 | return redirect()->back()->with('errors', $v->errors()); |
||
| 408 | } |
||
| 409 | |||
| 410 | try { |
||
| 411 | $licenseStatus = StatusSetting::pluck('license_status')->first(); |
||
| 412 | if ($licenseStatus) { |
||
| 413 | $addProductInLicensing = $this->licensing->editProduct($input['name'], $input['product_sku']); |
||
| 414 | } |
||
| 415 | $product = $this->product->where('id', $id)->first(); |
||
| 416 | if ($request->hasFile('image')) { |
||
| 417 | $image = $request->file('image')->getClientOriginalName(); |
||
| 418 | $imagedestinationPath = 'common/images'; |
||
| 419 | $request->file('image')->move($imagedestinationPath, $image); |
||
| 420 | $product->image = $image; |
||
| 421 | } |
||
| 422 | if ($request->hasFile('file')) { |
||
| 423 | $file = $request->file('file')->getClientOriginalName(); |
||
| 424 | $filedestinationPath = storage_path().'/products'; |
||
| 425 | $request->file('file')->move($filedestinationPath, $file); |
||
| 426 | $product->file = $file; |
||
| 427 | } |
||
| 428 | $product->fill($request->except('image', 'file'))->save(); |
||
| 429 | $this->saveCartDetailsWhileUpdating($input, $request, $product); |
||
| 430 | |||
| 431 | if ($request->input('github_owner') && $request->input('github_repository')) { |
||
| 432 | $this->updateVersionFromGithub($product->id, $request->input('github_owner'), $request->input('github_repository')); |
||
| 433 | } |
||
| 434 | //add tax class to tax_product_relation table |
||
| 435 | $newTax = $this->saveTax($request->input('tax'), $product->id); |
||
| 436 | |||
| 437 | return redirect()->back()->with('success', \Lang::get('message.updated-successfully')); |
||
| 438 | } catch (\Exception $e) { |
||
| 439 | Bugsnag::notifyException($e); |
||
| 440 | |||
| 441 | return redirect()->back()->with('fails', $e->getMessage()); |
||
| 442 | } |
||
| 443 | } |
||
| 444 | |||
| 445 | /** |
||
| 446 | * Remove the specified resource from storage. |
||
| 447 | * |
||
| 448 | * @param int $id |
||
| 449 | * |
||
| 450 | * @return \Response |
||
| 451 | */ |
||
| 452 | public function destroy(Request $request) |
||
| 453 | { |
||
| 454 | try { |
||
| 455 | $ids = $request->input('select'); |
||
| 456 | if (! empty($ids)) { |
||
| 457 | foreach ($ids as $id) { |
||
| 458 | $product = $this->product->where('id', $id)->first(); |
||
| 459 | if ($product) { |
||
| 460 | $licenseStatus = StatusSetting::pluck('license_status')->first(); |
||
| 461 | if ($licenseStatus == 1) { |
||
| 462 | $this->licensing->deleteProductFromAPL($product); |
||
| 463 | } |
||
| 464 | $product->delete(); |
||
| 465 | } else { |
||
| 466 | echo "<div class='alert alert-danger alert-dismissable'> |
||
| 467 | <i class='fa fa-ban'></i> |
||
| 468 | <b>"./* @scrutinizer ignore-type */\Lang::get('message.alert').'!</b> '. |
||
| 469 | /* @scrutinizer ignore-type */\Lang::get('message.failed').' |
||
| 470 | <button type=button class=close data-dismiss=alert aria-hidden=true>×</button> |
||
| 471 | './* @scrutinizer ignore-type */\Lang::get('message.no-record').' |
||
| 472 | </div>'; |
||
| 473 | //echo \Lang::get('message.no-record') . ' [id=>' . $id . ']'; |
||
| 474 | } |
||
| 475 | echo "<div class='alert alert-success alert-dismissable'> |
||
| 476 | <i class='fa fa-ban'></i> |
||
| 477 | <b>"./* @scrutinizer ignore-type */ |
||
| 478 | \Lang::get('message.alert').'!</b> './* @scrutinizer ignore-type */ \Lang::get('message.success').' |
||
| 479 | <button type=button class=close data-dismiss=alert aria-hidden=true>×</button> |
||
| 480 | './* @scrutinizer ignore-type */\Lang::get('message.deleted-successfully').' |
||
| 481 | </div>'; |
||
| 482 | } |
||
| 483 | } else { |
||
| 484 | echo "<div class='alert alert-danger alert-dismissable'> |
||
| 485 | <i class='fa fa-ban'></i> |
||
| 486 | <b>"./* @scrutinizer ignore-type */\Lang::get('message.alert').'!</b> '. |
||
| 487 | /* @scrutinizer ignore-type */\Lang::get('message.failed').' |
||
| 488 | <button type=button class=close data-dismiss=alert aria-hidden=true>×</button> |
||
| 489 | './* @scrutinizer ignore-type */\Lang::get('message.select-a-row').' |
||
| 490 | </div>'; |
||
| 491 | //echo \Lang::get('message.select-a-row'); |
||
| 492 | } |
||
| 493 | $lastActivity = Activity::all()->last(); |
||
| 494 | } catch (\Exception $e) { |
||
| 495 | echo "<div class='alert alert-danger alert-dismissable'> |
||
| 496 | <i class='fa fa-ban'></i> |
||
| 497 | <b>"./* @scrutinizer ignore-type */\Lang::get('message.alert').'!</b> '. |
||
| 498 | /* @scrutinizer ignore-type */\Lang::get('message.failed').' |
||
| 499 | <button type=button class=close data-dismiss=alert aria-hidden=true>×</button> |
||
| 500 | '.$e->getMessage().' |
||
| 501 | </div>'; |
||
| 502 | } |
||
| 503 | } |
||
| 504 | |||
| 505 | /** |
||
| 506 | * Remove the specified resource from storage. |
||
| 507 | * |
||
| 508 | * @param int $id |
||
| 509 | * |
||
| 510 | * @return \Response |
||
| 511 | */ |
||
| 512 | public function fileDestroy(Request $request) |
||
| 513 | { |
||
| 514 | try { |
||
| 515 | $ids = $request->input('select'); |
||
| 516 | $storagePath = Setting::find(1)->value('file_storage'); |
||
| 517 | if (! empty($ids)) { |
||
| 518 | foreach ($ids as $id) { |
||
| 519 | $product = $this->product_upload->where('id', $id)->first(); |
||
| 520 | if ($product) { |
||
| 521 | $file = $product->file; |
||
| 522 | unlink($storagePath.'/'.$file); |
||
| 523 | $product->delete(); |
||
| 524 | } else { |
||
| 525 | echo "<div class='alert alert-danger alert-dismissable'> |
||
| 526 | <i class='fa fa-ban'></i> |
||
| 527 | <b>".\Lang::get('message.alert').'!</b> '.\Lang::get('message.failed').' |
||
| 528 | <button type=button class=close data-dismiss=alert aria-hidden=true>×</button> |
||
| 529 | '.\Lang::get('message.no-record').' |
||
| 530 | </div>'; |
||
| 531 | //echo \Lang::get('message.no-record') . ' [id=>' . $id . ']'; |
||
| 532 | } |
||
| 533 | echo "<div class='alert alert-success alert-dismissable'> |
||
| 534 | <i class='fa fa-ban'></i> |
||
| 535 | <b>".\Lang::get('message.alert').'!</b> '.\Lang::get('message.success').' |
||
| 536 | <button type=button class=close data-dismiss=alert aria-hidden=true>×</button> |
||
| 537 | '.\Lang::get('message.deleted-successfully').' |
||
| 538 | </div>'; |
||
| 539 | } |
||
| 540 | } else { |
||
| 541 | echo "<div class='alert alert-danger alert-dismissable'> |
||
| 542 | <i class='fa fa-ban'></i> |
||
| 543 | <b>".\Lang::get('message.alert').'!</b> '.\Lang::get('message.failed').' |
||
| 544 | <button type=button class=close data-dismiss=alert aria-hidden=true>×</button> |
||
| 545 | '.\Lang::get('message.select-a-row').' |
||
| 546 | </div>'; |
||
| 547 | //echo \Lang::get('message.select-a-row'); |
||
| 548 | } |
||
| 549 | } catch (\Exception $e) { |
||
| 550 | echo "<div class='alert alert-danger alert-dismissable'> |
||
| 551 | <i class='fa fa-ban'></i> |
||
| 552 | <b>".\Lang::get('message.alert').'!</b> '.\Lang::get('message.failed').' |
||
| 553 | <button type=button class=close data-dismiss=alert aria-hidden=true>×</button> |
||
| 554 | '.$e->getMessage().' |
||
| 555 | </div>'; |
||
| 556 | } |
||
| 557 | } |
||
| 558 | |||
| 559 | /* |
||
| 560 | * Download Files from Filesystem/Github |
||
| 561 | */ |
||
| 562 | public function downloadProduct($uploadid, $id, $invoice_id, $version_id = '') |
||
| 563 | { |
||
| 564 | try { |
||
| 565 | $product = $this->product->findOrFail($uploadid); |
||
| 566 | $type = $product->type; |
||
| 567 | $owner = $product->github_owner; |
||
| 568 | $repository = $product->github_repository; |
||
| 569 | $file = $this->product_upload |
||
| 570 | ->where('product_id', '=', $uploadid) |
||
| 571 | ->where('id', $version_id)->select('file')->first(); |
||
| 572 | $order = Order::where('invoice_id', '=', $invoice_id)->first(); |
||
| 573 | $order_id = $order->id; |
||
| 574 | $relese = $this->getRelease($owner, $repository, $order_id, $file); |
||
| 575 | |||
| 576 | return $relese; |
||
| 577 | } catch (\Exception $e) { |
||
| 578 | Bugsnag::notifyException($e); |
||
| 579 | |||
| 580 | return redirect()->back()->with('fails', $e->getMessage()); |
||
| 581 | } |
||
| 582 | } |
||
| 583 | |||
| 584 | public function getSubscriptionCheckScript() |
||
| 599 | data: {'product': val, 'user': user,'plan':plan}, |
||
| 600 | //data: 'product=' + val+'user='+user, |
||
| 601 | success: function (data) { |
||
| 602 | var price = data['price']; |
||
| 603 | var field = data['field']; |
||
| 604 | $('#price').val(price); |
||
| 605 | $('#fields').append(field); |
||
| 606 | } |
||
| 607 | }); |
||
| 608 | } |
||
| 609 | |||
| 610 | </script>"; |
||
| 613 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.