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