ClientController   C
last analyzed

Complexity

Total Complexity 55

Size/Duplication

Total Lines 547
Duplicated Lines 0 %

Importance

Changes 2
Bugs 2 Features 0
Metric Value
wmc 55
eloc 348
dl 0
loc 547
rs 6
c 2
b 2
f 0

12 Methods

Rating   Name   Duplication   Size   Complexity  
B getGithubVersionList() 0 64 9
A getPaymentByOrderId() 0 45 3
A getPaymentByOrderIdClient() 0 37 3
B getOrder() 0 39 7
A getClientPanelOrdersData() 0 11 2
B getVersionList() 0 69 9
B getInvoices() 0 81 9
A __construct() 0 33 1
A profile() 0 37 4
A invoices() 0 6 2
A getOrders() 0 42 3
A getInvoice() 0 18 3

How to fix   Complexity   

Complex Class

Complex classes like ClientController 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 ClientController, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace App\Http\Controllers\Front;
4
5
use App\Http\Controllers\Github\GithubApiController;
6
use App\Http\Controllers\License\LicensePermissionsController;
7
use App\Model\Common\StatusSetting;
8
use App\Model\Github\Github;
9
use App\Model\Order\Invoice;
10
use App\Model\Order\Order;
11
use App\Model\Order\Payment;
12
use App\Model\Product\Product;
13
use App\Model\Product\ProductUpload;
14
use App\Model\Product\Subscription;
15
use App\User;
16
use Bugsnag;
17
use Exception;
18
use GrahamCampbell\Markdown\Facades\Markdown;
19
20
class ClientController extends BaseClientController
21
{
22
    public $user;
23
    public $invoice;
24
    public $order;
25
    public $subscription;
26
    public $payment;
27
28
    public function __construct()
29
    {
30
        $this->middleware('auth');
31
32
        $user = new User();
33
        $this->user = $user;
34
35
        $invoice = new Invoice();
36
        $this->invoice = $invoice;
37
38
        $order = new Order();
39
        $this->order = $order;
40
41
        $subscription = new Subscription();
42
        $this->subscription = $subscription;
43
44
        $payment = new Payment();
45
        $this->payment = $payment;
46
47
        $product_upload = new ProductUpload();
48
        $this->product_upload = $product_upload;
49
50
        $product = new Product();
51
        $this->product = $product;
52
53
        $github_controller = new GithubApiController();
54
        $this->github_api = $github_controller;
55
56
        $model = new Github();
57
        $this->github = $model->firstOrFail();
58
59
        $this->client_id = $this->github->client_id;
60
        $this->client_secret = $this->github->client_secret;
61
    }
62
63
    public function invoices()
64
    {
65
        try {
66
            return view('themes.default1.front.clients.invoice');
67
        } catch (Exception $ex) {
68
            return redirect()->back()->with('fails', $ex->getMessage());
69
        }
70
    }
71
72
    public function getInvoices()
73
    {
74
        try {
75
            $invoices = Invoice::leftJoin('order_invoice_relations', 'invoices.id', '=', 'order_invoice_relations.invoice_id')
76
            ->select('invoices.id', 'invoices.user_id', 'invoices.date', 'invoices.number', 'invoices.grand_total', 'order_invoice_relations.order_id', 'invoices.is_renewed', 'invoices.status')
77
            ->groupBy('invoices.number')
78
            ->where('invoices.user_id', '=', \Auth::user()->id)
79
            ->orderBy('invoices.created_at', 'desc')
80
            ->get();
81
82
            return \DataTables::of($invoices)
83
                            ->addColumn('number', function ($model) {
84
                                if ($model->is_renewed) {
85
                                    return '<a href='.url('my-invoice/'.$model->id).'>'.$model->number.'</a>&nbsp;'.getStatusLabel('renewed', 'badge');
86
                                } else {
87
                                    return '<a href='.url('my-invoice/'.$model->id).'>'.$model->number.'</a>';
88
                                }
89
                            })
90
                           ->addColumn('orderNo', function ($model) {
91
                               if ($model->is_renewed) {
92
                                   return Order::find($model->order_id)->first()->getOrderLink($model->order_id, 'my-order');
93
                               } else {
94
                                   $allOrders = $model->order()->select('id', 'number')->get();
95
                                   $orderArray = '';
96
                                   foreach ($allOrders as $orders) {
97
                                       $orderArray .= $orders->getOrderLink($orders->id, 'orders');
98
                                   }
99
100
                                   return $orderArray;
101
                               }
102
                           })
103
                            ->addColumn('date', function ($model) {
104
                                return getDateHtml($model->created_at);
105
                            })
106
                            ->addColumn('total', function ($model) {
107
                                return  currencyFormat($model->grand_total, $code = \Auth::user()->currency);
108
                            })
109
                            ->addColumn('paid', function ($model) {
110
                                $payment = \App\Model\Order\Payment::where('invoice_id', $model->id)->select('amount')->get();
111
                                $c = count($payment);
112
                                $sum = 0;
113
114
                                for ($i = 0; $i <= $c - 1; $i++) {
115
                                    $sum = $sum + $payment[$i]->amount;
116
                                }
117
118
                                return currencyFormat($sum, $code = \Auth::user()->currency);
119
                            })
120
                             ->addColumn('balance', function ($model) {
121
                                 $payment = \App\Model\Order\Payment::where('invoice_id', $model->id)->select('amount')->get();
122
                                 $c = count($payment);
123
                                 $sum = 0;
124
125
                                 for ($i = 0; $i <= $c - 1; $i++) {
126
                                     $sum = $sum + $payment[$i]->amount;
127
                                 }
128
                                 $pendingAmount = ($model->grand_total) - ($sum);
129
130
                                 return currencyFormat($pendingAmount, $code = \Auth::user()->currency);
131
                             })
132
                             ->addColumn('status', function ($model) {
133
                                 return  getStatusLabel($model->status, 'badge');
134
                             })
135
                            ->addColumn('Action', function ($model) {
136
                                $status = $model->status;
137
                                $payment = '';
138
                                if ($status != 'Success' && $model->grand_total > 0) {
139
                                    $payment = '  <a href='.url('paynow/'.$model->id).
140
                                    " class='btn btn-primary btn-xs'><i class='fa fa-credit-card'></i>&nbsp;Pay Now</a>";
141
                                }
142
143
                                return '<p><a href='.url('my-invoice/'.$model->id).
144
                                " class='btn btn-primary btn-xs'><i class='fa fa-eye'></i>&nbsp;View</a>".$payment.'</p>';
145
                            })
146
147
                            ->rawColumns(['number', 'orderNo', 'date', 'total', 'status', 'Action'])
148
                            // ->orderColumns('number', 'created_at', 'total')
149
                            ->make(true);
150
        } catch (Exception $ex) {
151
            Bugsnag::notifyException($ex);
152
            echo $ex->getMessage();
153
        }
154
    }
155
156
    public function getInvoice($id)
157
    {
158
        try {
159
            $invoice = $this->invoice->findOrFail($id);
160
            $user = \Auth::user();
161
            if ($invoice->user_id != $user->id) {
162
                throw new \Exception('Cannot view invoice. Invalid modification of data.');
163
            }
164
            $items = $invoice->invoiceItem()->get();
165
            $order = $this->order->getOrderLink($invoice->orderRelation()->value('order_id'), 'my-order');
166
            $currency = userCurrency($user->id);
167
            $symbol = $currency['symbol'];
168
169
            return view('themes.default1.front.clients.show-invoice', compact('invoice', 'items', 'user', 'currency', 'symbol', 'order'));
170
        } catch (Exception $ex) {
171
            Bugsnag::notifyException($ex);
172
173
            return redirect()->back()->with('fails', $ex->getMessage());
174
        }
175
    }
176
177
    /**
178
     * Get list of all the versions from Filesystem.
179
     *
180
     * @param type $productid
181
     * @param type $clientid
182
     * @param type $invoiceid
183
     *
184
     * Get list of all the versions from Filesystem.
185
     * @param type $productid
186
     * @param type $clientid
187
     * @param type $invoiceid
188
     *
189
     * @return type
190
     */
191
    public function getVersionList($productid, $clientid, $invoiceid)
192
    {
193
        try {
194
            $versions = ProductUpload::where('product_id', $productid)
195
            ->select(
196
                'id',
197
                'product_id',
198
                'version',
199
                'title',
200
                'description',
201
                'file',
202
                'created_at'
203
            )->get();
204
            $countVersions = count($versions);
205
            $countExpiry = 0;
206
            $invoice_id = Invoice::where('number', $invoiceid)->pluck('id')->first();
207
            $order = Order::where('invoice_id', '=', $invoice_id)->first();
208
209
            $order_id = $order->id;
210
            $updatesEndDate = Subscription::select('update_ends_at')
211
                 ->where('product_id', $productid)->where('order_id', $order_id)->first();
212
            if ($updatesEndDate) {
213
                foreach ($versions as $version) {
214
                    if ($version->created_at->toDateTimeString()
215
                    < $updatesEndDate->update_ends_at || $updatesEndDate->update_ends_at == '0000-00-00 00:00:00') {
216
                        $countExpiry = $countExpiry + 1;
217
                    }
218
                }
219
            }
220
221
            return \DataTables::of($versions)
222
                            ->addColumn('id', function ($versions) {
223
                                return ucfirst($versions->id);
224
                            })
225
                            ->addColumn('version', function ($versions) {
226
                                return ucfirst($versions->version);
227
                            })
228
                            ->addColumn('title', function ($versions) {
229
                                return ucfirst($versions->title);
230
                            })
231
                            ->addColumn('description', function ($versions) {
232
                                return ucfirst($versions->description);
233
                            })
234
                            ->addColumn('file', function ($versions) use ($countExpiry, $countVersions, $clientid, $invoiceid, $productid) {
235
                                $invoice_id = Invoice::where('number', $invoiceid)->pluck('id')->first();
236
                                $order = Order::where('invoice_id', '=', $invoice_id)->first();
237
                                $order_id = $order->id;
238
                                $downloadPermission = LicensePermissionsController::getPermissionsForProduct($productid);
239
                                $updateEndDate = Subscription::select('update_ends_at')
240
                                ->where('product_id', $productid)->where('order_id', $order_id)->first();
241
242
                                //if product has Update expiry date ie subscription is generated
243
                                if ($updateEndDate) {
244
                                    if ($downloadPermission['allowDownloadTillExpiry'] == 1) {//Perpetual download till expiry permission selected
245
                                        $getDownload = $this->whenDownloadTillExpiry($updateEndDate, $productid, $versions, $clientid, $invoiceid);
246
247
                                        return $getDownload;
248
                                    } elseif ($downloadPermission['allowDownloadTillExpiry'] == 0) {//When download retires after subscription
249
                                        $getDownload = $this->whenDownloadExpiresAfterExpiry($countExpiry, $countVersions, $updateEndDate, $productid, $versions, $clientid, $invoiceid);
250
251
                                        return $getDownload;
252
                                    }
253
                                }
254
                            })
255
                            ->rawColumns(['version', 'title', 'description', 'file'])
256
                            ->make(true);
257
        } catch (Exception $ex) {
258
            Bugsnag::notifyException($ex);
259
            echo $ex->getMessage();
260
        }
261
    }
262
263
    /**
264
     * Get list of all the versions from Github.
265
     *
266
     * @param type $productid
267
     * @param type $clientid
268
     * @param type $invoiceid
269
     */
270
    public function getGithubVersionList($productid, $clientid, $invoiceid)
271
    {
272
        try {
273
            $products = $this->product::where('id', $productid)
274
            ->select('name', 'version', 'github_owner', 'github_repository')->get();
275
            $owner = '';
276
            $repo = '';
277
            foreach ($products as $product) {
278
                $owner = $product->github_owner;
279
                $repo = $product->github_repository;
280
            }
281
            $url = "https://api.github.com/repos/$owner/$repo/releases";
282
            $countExpiry = 0;
283
            $link = $this->github_api->getCurl1($url);
284
            $link = $link['body'];
285
            $countVersions = 10; //because we are taking only the first 10 versions
286
            $link = (array_slice($link, 0, 10, true));
287
            $order = Order::where('invoice_id', '=', $invoiceid)->first();
288
            $order_id = $order->id;
289
            $orderEndDate = Subscription::select('update_ends_at')
290
                        ->where('product_id', $productid)->where('order_id', $order_id)->first();
291
            if ($orderEndDate) {
292
                foreach ($link as $lin) {
293
                    if (strtotime($lin['created_at']) < strtotime($orderEndDate->update_ends_at) || $orderEndDate->update_ends_at == '0000-00-00 00:00:00') {
294
                        $countExpiry = $countExpiry + 1;
295
                    }
296
                }
297
            }
298
299
            return \DataTables::of($link)
300
                            ->addColumn('version', function ($link) {
301
                                return ucfirst($link['tag_name']);
302
                            })
303
                            ->addColumn('name', function ($link) {
304
                                return ucfirst($link['name']);
305
                            })
306
                            ->addColumn('description', function ($link) {
307
                                $markdown = Markdown::convertToHtml(ucfirst($link['body']));
308
309
                                return $markdown;
310
                            })
311
                            ->addColumn('file', function ($link) use ($countExpiry, $countVersions, $invoiceid, $productid) {
312
                                $order = Order::where('invoice_id', '=', $invoiceid)->first();
313
                                $order_id = $order->id;
314
                                $orderEndDate = Subscription::select('update_ends_at')
315
                                ->where('product_id', $productid)->where('order_id', $order_id)->first();
316
                                if ($orderEndDate) {
317
                                    $actionButton = $this->getActionButton($countExpiry, $countVersions, $link, $orderEndDate, $productid);
318
319
                                    return $actionButton;
320
                                } elseif (! $orderEndDate) {
321
                                    $link = $this->github_api->getCurl1($link['zipball_url']);
322
323
                                    return '<p><a href='.$link['header']['Location']
324
                                    ." class='btn btn-sm btn-primary'>Download  </a>"
325
                                            .'&nbsp;
326
                                   </p>';
327
                                }
328
                            })
329
                            ->rawColumns(['version', 'name', 'description', 'file'])
330
                            ->make(true);
331
        } catch (Exception $ex) {
332
            Bugsnag::notifyException($ex);
333
            echo $ex->getMessage();
334
        }
335
    }
336
337
    /*
338
     * Show all the orders for User
339
     */
340
341
    public function getOrders()
342
    {
343
        try {
344
            $orders = $this->getClientPanelOrdersData();
345
346
            return \DataTables::of($orders)
347
                            ->addColumn('id', function ($model) {
348
                                return $model->id;
349
                            })
350
                            ->addColumn('product_name', function ($model) {
351
                                return $model->product_name;
352
                            })
353
                            ->addColumn('number', function ($model) {
354
                                return '<a href='.url('my-order/'.$model->id).'>'.$model->number.'</a>';
355
                            })
356
                            ->addColumn('version', function ($model) {
357
                                return getVersionAndLabel($model->version, $model->product_id, 'badge');
358
                            })
359
                            ->addColumn('expiry', function ($model) {
360
                                return getExpiryLabel($model->update_ends_at, 'badge');
361
                            })
362
363
                            ->addColumn('Action', function ($model) {
364
                                $order_cont = new \App\Http\Controllers\Order\OrderController();
365
                                $status = $order_cont->checkInvoiceStatusByOrderId($model->id);
366
                                $url = '';
367
                                if ($status == 'success') {
368
                                    $url = $this->renewPopup($model->sub_id, $model->product_id);
369
                                }
370
371
                                $listUrl = $this->getPopup($model, $model->product_id);
372
373
                                return '<a href='.url('my-order/'.$model->id)." 
374
                                class='btn  btn-primary btn-xs' style='margin-right:5px;'>
375
                                <i class='fa fa-eye' title='Details of order'></i>&nbsp;View $listUrl $url </a>";
376
                            })
377
                            ->rawColumns(['id', 'product_name', 'number', 'version', 'expiry', 'Action'])
378
                            ->make(true);
379
        } catch (Exception $ex) {
380
            app('log')->error($ex->getMessage());
381
            Bugsnag::notifyException($ex);
382
            echo $ex->getMessage();
383
        }
384
    }
385
386
    public function getClientPanelOrdersData()
387
    {
388
        return Order::leftJoin('products', 'products.id', '=', 'orders.product')
389
            ->leftJoin('subscriptions', 'orders.id', '=', 'subscriptions.order_id')
390
            ->leftJoin('invoices', 'orders.invoice_id', 'invoices.id')
391
            ->select('products.name as product_name', 'products.github_owner', 'products.github_repository', 'products.type', 'products.id as product_id', 'orders.id', 'orders.number', 'orders.client', 'subscriptions.id as sub_id', 'subscriptions.version', 'subscriptions.update_ends_at', 'products.name', 'orders.client', 'invoices.id as invoice_id', 'invoices.number as invoice_number')
392
            ->where('orders.client', \Auth::user()->id)
393
            ->get()->map(function ($element) {
394
                $element->update_ends_at = strtotime($element->update_ends_at) > 1 ? $element->update_ends_at : '--';
395
396
                return $element;
397
            });
398
    }
399
400
    public function profile()
401
    {
402
        try {
403
            $user = $this->user->where('id', \Auth::user()->id)->first();
404
            $is2faEnabled = $user->is_2fa_enabled;
405
            $dateSinceEnabled = $user->google2fa_activation_date;
406
            $timezonesList = \App\Model\Common\Timezone::get();
407
            foreach ($timezonesList as $timezone) {
408
                $location = $timezone->location;
409
                if ($location) {
410
                    $start = strpos($location, '(');
411
                    $end = strpos($location, ')', $start + 1);
412
                    $length = $end - $start;
413
                    $result = substr($location, $start + 1, $length - 1);
414
                    $display[] = (['id'=>$timezone->id, 'name'=> '('.$result.')'.' '.$timezone->name]);
415
                }
416
            }
417
            //for display
418
            $timezones = array_column($display, 'name', 'id');
419
            $state = getStateByCode($user->state);
420
            $states = findStateByRegionId($user->country);
421
            $bussinesses = \App\Model\Common\Bussiness::pluck('name', 'short')->toArray();
422
            $selectedIndustry = \App\Model\Common\Bussiness::where('name', $user->bussiness)
423
            ->pluck('name', 'short')->toArray();
424
            $selectedCompany = \DB::table('company_types')->where('name', $user->company_type)
425
            ->pluck('name', 'short')->toArray();
426
            $selectedCompanySize = \DB::table('company_sizes')->where('short', $user->company_size)
427
            ->pluck('name', 'short')->toArray();
428
429
            return view(
430
                'themes.default1.front.clients.profile',
431
                compact('user', 'timezones', 'state', 'states', 'bussinesses', 'is2faEnabled', 'dateSinceEnabled', 'selectedIndustry', 'selectedCompany', 'selectedCompanySize')
432
            );
433
        } catch (Exception $ex) {
434
            Bugsnag::notifyException($ex);
435
436
            return redirect()->back()->with('fails', $ex->getMessage());
437
        }
438
    }
439
440
    public function getOrder($id)
441
    {
442
        try {
443
            $user = \Auth::user();
444
            $order = $this->order->findOrFail($id);
445
            if ($order->client != $user->id) {
446
                throw new \Exception('Cannot view order. Invalid modification of data.');
447
            }
448
            $invoice = $order->invoice()->first();
449
            $items = $order->invoice()->first()->invoiceItem()->get();
450
            $subscription = $order->subscription()->first();
451
            $date = '--';
452
            $licdate = '--';
453
            $versionLabel = '--';
454
            if ($subscription) {
455
                $date = strtotime($subscription->update_ends_at) > 1 ? getExpiryLabel($subscription->update_ends_at, 'badge') : '--';
456
                $licdate = strtotime($subscription->ends_at) > 1 ? getExpiryLabel($subscription->ends_at, 'badge') : '--';
457
                $versionLabel = getVersionAndLabel($subscription->version, $order->product, 'badge');
458
            }
459
460
            $installationDetails = [];
461
            $licenseStatus = StatusSetting::pluck('license_status')->first();
462
            if ($licenseStatus == 1) {
463
                $cont = new \App\Http\Controllers\License\LicenseController();
464
                $installationDetails = $cont->searchInstallationPath($order->serial_key, $order->product);
465
            }
466
            $product = $order->product()->first();
467
            $price = $product->price()->first();
468
            $licenseStatus = StatusSetting::pluck('license_status')->first();
469
            $allowDomainStatus = StatusSetting::pluck('domain_check')->first();
470
471
            return view(
472
                'themes.default1.front.clients.show-order',
473
                compact('invoice', 'order', 'user', 'product', 'subscription', 'licenseStatus', 'installationDetails', 'allowDomainStatus', 'date', 'licdate', 'versionLabel')
474
            );
475
        } catch (Exception $ex) {
476
            Bugsnag::notifyException($ex);
477
478
            return redirect()->back()->with('fails', $ex->getMessage());
479
        }
480
    }
481
482
    public function getPaymentByOrderId($orderid, $userid)
483
    {
484
        try {
485
            // dd($orderid);
486
            $order = $this->order->where('id', $orderid)->where('client', $userid)->first();
487
            // dd($order);
488
            $relation = $order->invoiceRelation()->pluck('invoice_id')->toArray();
489
            if (count($relation) > 0) {
490
                $invoices = $relation;
491
            } else {
492
                $invoices = $order->invoice()->pluck('id')->toArray();
493
            }
494
            $payments = $this->payment->whereIn('invoice_id', $invoices)
495
                    ->select('id', 'invoice_id', 'user_id', 'amount', 'payment_method', 'payment_status', 'created_at');
496
497
            return \DataTables::of($payments->get())
498
                            ->addColumn('checkbox', function ($model) {
499
                                return "<input type='checkbox' class='payment_checkbox' 
500
                                    value=".$model->id.' name=select[] id=check>';
501
                            })
502
                            ->addColumn('number', function ($model) {
503
                                return $model->invoice()->first()->number;
504
                            })
505
                            ->addColumn('amount', function ($model) {
506
                                $currency = $model->invoice()->first()->currency;
507
                                $total = currencyFormat($model->amount, $code = $currency);
508
509
                                return $total;
510
                            })
511
                            ->addColumn('payment_method', function ($model) {
512
                                return $model->payment_method;
513
                            })
514
                             ->addColumn('payment_status', function ($model) {
515
                                 return $model->payment_status;
516
                             })
517
                            ->addColumn('created_at', function ($model) {
518
                                return getDateHtml($model->created_at);
519
                            })
520
                            ->rawColumns(['checkbox', 'number', 'amount',
521
                                'payment_method', 'payment_status', 'created_at', ])
522
                            ->make(true);
523
        } catch (Exception $ex) {
524
            Bugsnag::notifyException($ex);
525
526
            return redirect()->back()->with('fails', $ex->getMessage());
527
        }
528
    }
529
530
    public function getPaymentByOrderIdClient($orderid, $userid)
531
    {
532
        try {
533
            $order = $this->order->where('id', $orderid)->where('client', $userid)->first();
534
            // dd($order);
535
            $relation = $order->invoiceRelation()->pluck('invoice_id')->toArray();
536
            if (count($relation) > 0) {
537
                $invoices = $relation;
538
            } else {
539
                $invoices = $order->invoice()->pluck('id')->toArray();
540
            }
541
            // $payments = Payment::leftJoin('invoices', 'payments.invoice_id', '=', 'invoices.id')
542
            // ->select('payments.id', 'payments.invoice_id', 'payments.user_id', 'payments.payment_method', 'payments.payment_status', 'payments.created_at', 'payments.amount', 'invoices.id as invoice_id', 'invoices.number as invoice_number')
543
            // ->where('invoices.id', $invoices)
544
            // ->get();
545
            $payments = $this->payment->whereIn('invoice_id', $invoices)
546
                    ->select('id', 'invoice_id', 'user_id', 'amount', 'payment_method', 'payment_status', 'created_at');
547
548
            return \DataTables::of($payments->get())
549
                            ->addColumn('number', function ($payments) {
550
                                return '<a href='.url('my-invoice/'.$payments->invoice()->first()->id).'>'.$payments->invoice()->first()->number.'</a>';
551
                            })
552
                              ->addColumn('total', function ($payments) {
553
                                  return $payments->amount;
554
                              })
555
                               ->addColumn('created_at', function ($payments) {
556
                                   return  getDateHtml($payments->created_at);
557
                               })
558
559
                            ->addColumn('payment_method', 'payment_status', 'created_at')
560
561
                            ->rawColumns(['number', 'total', 'payment_method', 'payment_status', 'created_at'])
562
                            ->make(true);
563
        } catch (Exception $ex) {
564
            Bugsnag::notifyException($ex);
565
566
            return redirect()->back()->with('fails', $ex->getMessage());
567
        }
568
    }
569
}
570