@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | |
24 | 24 | class ShopPaymentController extends Controller |
25 | 25 | { |
26 | - public function page(){ |
|
26 | + public function page() { |
|
27 | 27 | $total = session('checkout.total'); |
28 | 28 | $api_stripe_key = AdminSetting::getStripeApiKey(); |
29 | 29 | $iban = AdminSetting::getIban(); |
30 | - return view('mongicommerce.pages.payment',compact('total','api_stripe_key','iban')); |
|
30 | + return view('mongicommerce.pages.payment', compact('total', 'api_stripe_key', 'iban')); |
|
31 | 31 | } |
32 | 32 | |
33 | - public function pay(Request $request){ |
|
33 | + public function pay(Request $request) { |
|
34 | 34 | |
35 | 35 | try { |
36 | 36 | $total = session('checkout.total'); |
@@ -38,16 +38,16 @@ discard block |
||
38 | 38 | $order_weight = session('checkout.total_weight'); |
39 | 39 | |
40 | 40 | $order_id = 0; |
41 | - $check_order = Order::orderBy('created_at','desc')->first(); |
|
42 | - if(is_null($check_order)){ |
|
41 | + $check_order = Order::orderBy('created_at', 'desc')->first(); |
|
42 | + if (is_null($check_order)) { |
|
43 | 43 | $order_id = 1; |
44 | - }else{ |
|
44 | + } else { |
|
45 | 45 | $order_id = $check_order->id + 1; |
46 | 46 | } |
47 | 47 | Stripe::setApiKey(AdminSetting::getStripeApiSecretKey()); |
48 | 48 | // Use Stripe's library to make requests... |
49 | - Charge::create ([ |
|
50 | - "amount" => number_format(($total*100) , 0, '', ''), |
|
49 | + Charge::create([ |
|
50 | + "amount" => number_format(($total * 100), 0, '', ''), |
|
51 | 51 | "currency" => "eur", |
52 | 52 | "source" => $request->stripeToken, |
53 | 53 | "description" => "Pagamento ordine N.".$order_id |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | $order->save(); |
69 | 69 | //save into order_products |
70 | 70 | |
71 | - $products = Cart::where('user_id',Auth::user()->id)->get(); |
|
72 | - foreach ($products as $product){ |
|
71 | + $products = Cart::where('user_id', Auth::user()->id)->get(); |
|
72 | + foreach ($products as $product) { |
|
73 | 73 | $order_products = new ProductsOrder(); |
74 | 74 | $order_products->order_id = $order->id; |
75 | 75 | $order_products->product_item_id = $product->product_item_id; |
@@ -87,15 +87,15 @@ discard block |
||
87 | 87 | Session::flash('success', 'Pagamento avvenuto con successo'); |
88 | 88 | return redirect(route('shop.user.orders')); |
89 | 89 | |
90 | - } catch(CardException $e) { |
|
90 | + } catch (CardException $e) { |
|
91 | 91 | |
92 | 92 | // Since it's a decline, \Stripe\Exception\CardException will be caught |
93 | - $error = '<h4>'.$e->getError()->message.'</h4><br>'; |
|
94 | - $error .= 'Status: ' . $e->getHttpStatus() . '<br>'; |
|
95 | - $error .= 'Type is:' . $e->getError()->type . '<br>'; |
|
96 | - $error .= 'Code is:' . $e->getError()->code . '<br>'; |
|
93 | + $error = '<h4>'.$e->getError()->message.'</h4><br>'; |
|
94 | + $error .= 'Status: '.$e->getHttpStatus().'<br>'; |
|
95 | + $error .= 'Type is:'.$e->getError()->type.'<br>'; |
|
96 | + $error .= 'Code is:'.$e->getError()->code.'<br>'; |
|
97 | 97 | // param is '' in this case |
98 | - $error .= 'Param is:' . $e->getError()->param . '<br>'; |
|
98 | + $error .= 'Param is:'.$e->getError()->param.'<br>'; |
|
99 | 99 | |
100 | 100 | Session::flash('error', $error); |
101 | 101 | return back(); |
@@ -135,9 +135,9 @@ discard block |
||
135 | 135 | |
136 | 136 | } |
137 | 137 | |
138 | - public function normalPayment(Request $r){ |
|
138 | + public function normalPayment(Request $r) { |
|
139 | 139 | $type = $r->get('type_payment'); |
140 | - switch ($type){ |
|
140 | + switch ($type) { |
|
141 | 141 | case 'iban': |
142 | 142 | $typePayment = TypePayment::BONIFICO; |
143 | 143 | $orderStatus = OrderStatus::ATTESA_PAGAMENTO; |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | |
170 | 170 | //save into order_products |
171 | 171 | |
172 | - $products = Cart::where('user_id',Auth::user()->id)->get(); |
|
173 | - foreach ($products as $product){ |
|
172 | + $products = Cart::where('user_id', Auth::user()->id)->get(); |
|
173 | + foreach ($products as $product) { |
|
174 | 174 | $order_products = new ProductsOrder(); |
175 | 175 | $order_products->order_id = $order->id; |
176 | 176 | $order_products->product_item_id = $product->product_item_id; |
@@ -19,10 +19,10 @@ |
||
19 | 19 | return view('mongicommerce.pages.login'); |
20 | 20 | } |
21 | 21 | |
22 | - public function store(LoginRequest $request){ |
|
22 | + public function store(LoginRequest $request) { |
|
23 | 23 | $request->authenticate(); |
24 | 24 | $request->session()->regenerate(); |
25 | - return Redirect::back()->with('message','Loggato con successo!'); |
|
25 | + return Redirect::back()->with('message', 'Loggato con successo!'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | public function storeAndRedirect(LoginRequest $request) |
@@ -43,7 +43,7 @@ |
||
43 | 43 | 'email_verified_at' => 'datetime', |
44 | 44 | ]; |
45 | 45 | |
46 | - public function orders(){ |
|
47 | - return $this->hasMany(Order::class,'user_id'); |
|
46 | + public function orders() { |
|
47 | + return $this->hasMany(Order::class, 'user_id'); |
|
48 | 48 | } |
49 | 49 | } |
@@ -10,17 +10,17 @@ |
||
10 | 10 | { |
11 | 11 | use HasFactory; |
12 | 12 | |
13 | - public static function getStripeApiKey(){ |
|
13 | + public static function getStripeApiKey() { |
|
14 | 14 | $globalSetting = self::first(); |
15 | 15 | return $globalSetting->stripe_api_key; |
16 | 16 | } |
17 | 17 | |
18 | - public static function getStripeApiSecretKey(){ |
|
18 | + public static function getStripeApiSecretKey() { |
|
19 | 19 | $globalSetting = self::first(); |
20 | 20 | return $globalSetting->stripe_api_secret; |
21 | 21 | } |
22 | 22 | |
23 | - public static function getIban(){ |
|
23 | + public static function getIban() { |
|
24 | 24 | $globalSetting = self::first(); |
25 | 25 | return $globalSetting->iban; |
26 | 26 | } |
@@ -14,21 +14,21 @@ |
||
14 | 14 | { |
15 | 15 | use HasFactory; |
16 | 16 | |
17 | - protected $dates = ["created_at","updated_at"]; |
|
17 | + protected $dates = ["created_at", "updated_at"]; |
|
18 | 18 | |
19 | - public function status(){ |
|
20 | - return $this->belongsTo(OrderStatus::class,'status_id'); |
|
19 | + public function status() { |
|
20 | + return $this->belongsTo(OrderStatus::class, 'status_id'); |
|
21 | 21 | } |
22 | 22 | |
23 | - public function typePayment(){ |
|
24 | - return $this->belongsTo(TypePayment::class,'payment_type_id'); |
|
23 | + public function typePayment() { |
|
24 | + return $this->belongsTo(TypePayment::class, 'payment_type_id'); |
|
25 | 25 | } |
26 | 26 | |
27 | - public function user(){ |
|
28 | - return $this->belongsTo(User::class,'user_id'); |
|
27 | + public function user() { |
|
28 | + return $this->belongsTo(User::class, 'user_id'); |
|
29 | 29 | } |
30 | 30 | |
31 | - public function products(){ |
|
32 | - return $this->belongsToMany(ProductItem::class,'product_order','order_id','product_item_id')->withPivot('number_products'); |
|
31 | + public function products() { |
|
32 | + return $this->belongsToMany(ProductItem::class, 'product_order', 'order_id', 'product_item_id')->withPivot('number_products'); |
|
33 | 33 | } |
34 | 34 | } |
@@ -12,15 +12,15 @@ |
||
12 | 12 | { |
13 | 13 | use HasFactory; |
14 | 14 | protected $table = 'cart'; |
15 | - protected $dates = ["created_at","updated_at"]; |
|
15 | + protected $dates = ["created_at", "updated_at"]; |
|
16 | 16 | |
17 | 17 | |
18 | - public function user(){ |
|
19 | - return $this->belongsTo(User::class,'user_id'); |
|
18 | + public function user() { |
|
19 | + return $this->belongsTo(User::class, 'user_id'); |
|
20 | 20 | } |
21 | 21 | |
22 | - static function emptyCart(){ |
|
23 | - self::where('user_id',Auth::user()->id)->delete(); |
|
22 | + static function emptyCart() { |
|
23 | + self::where('user_id', Auth::user()->id)->delete(); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::create('product_order', function (Blueprint $table) { |
|
16 | + Schema::create('product_order', function(Blueprint $table) { |
|
17 | 17 | $table->id(); |
18 | 18 | $table->unsignedBigInteger('order_id'); |
19 | 19 | $table->unsignedBigInteger('product_item_id'); |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function up() |
15 | 15 | { |
16 | - Schema::table('users', function (Blueprint $table) { |
|
16 | + Schema::table('users', function(Blueprint $table) { |
|
17 | 17 | $table->string('name')->nullable()->change(); |
18 | 18 | $table->string('first_name')->nullable(); |
19 | 19 | $table->string('last_name')->nullable(); |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | use Mongi\Mongicommerce\Http\Controllers\admin\AdminNewProductVariationController; |
28 | 28 | |
29 | 29 | |
30 | -Route::group(['middleware' => ['web']], function () { |
|
30 | +Route::group(['middleware' => ['web']], function() { |
|
31 | 31 | /***************** |
32 | 32 | *-----SHOP------* |
33 | 33 | *****************/ |
@@ -49,27 +49,27 @@ discard block |
||
49 | 49 | Route::get('/page/shop/user/settings', [ShopUserController::class, 'page'])->name('shop.user.settings'); |
50 | 50 | |
51 | 51 | |
52 | - Route::get('/shop/{id?}',[ShopController::class,'page'])->name('shop'); |
|
53 | - Route::get('/prodotto/{id}/{item_id?}',[ShopSingleProductController::class,'page'])->name('shop.single.product'); |
|
54 | - Route::get('page/shop/cart/',[ShopCartController::class,'page'])->name('shop.cart'); |
|
55 | - Route::get('page/shop/summary/',[ShopSummaryController::class,'page'])->name('shop.summary'); |
|
56 | - Route::get('page/shop/shipment/',[ShopShipmentController::class,'page'])->name('shop.shipment'); |
|
57 | - Route::get('page/shop/checkout/',[ShopCheckoutController::class,'page'])->name('shop.checkout'); |
|
58 | - Route::get('page/shop/payment/',[ShopPaymentController::class,'page'])->name('shop.payment'); |
|
52 | + Route::get('/shop/{id?}', [ShopController::class, 'page'])->name('shop'); |
|
53 | + Route::get('/prodotto/{id}/{item_id?}', [ShopSingleProductController::class, 'page'])->name('shop.single.product'); |
|
54 | + Route::get('page/shop/cart/', [ShopCartController::class, 'page'])->name('shop.cart'); |
|
55 | + Route::get('page/shop/summary/', [ShopSummaryController::class, 'page'])->name('shop.summary'); |
|
56 | + Route::get('page/shop/shipment/', [ShopShipmentController::class, 'page'])->name('shop.shipment'); |
|
57 | + Route::get('page/shop/checkout/', [ShopCheckoutController::class, 'page'])->name('shop.checkout'); |
|
58 | + Route::get('page/shop/payment/', [ShopPaymentController::class, 'page'])->name('shop.payment'); |
|
59 | 59 | |
60 | 60 | |
61 | 61 | |
62 | - Route::post('/shop/get/product-information',[ShopShowVariationProductController::class,'getData'])->name('shop.get.product.information'); |
|
63 | - Route::post('/shop/addtocart',[ShopCartController::class,'addToCart'])->name('shop.addtocart'); |
|
64 | - Route::post('/shop/getcartelements',[ShopCartController::class,'getCartElements'])->name('shop.getcartelements'); |
|
62 | + Route::post('/shop/get/product-information', [ShopShowVariationProductController::class, 'getData'])->name('shop.get.product.information'); |
|
63 | + Route::post('/shop/addtocart', [ShopCartController::class, 'addToCart'])->name('shop.addtocart'); |
|
64 | + Route::post('/shop/getcartelements', [ShopCartController::class, 'getCartElements'])->name('shop.getcartelements'); |
|
65 | 65 | |
66 | - Route::post('/shop/getcartproducts/',[ShopCartController::class,'getCartProducts'])->name('getcartproducts'); |
|
67 | - Route::post('/shop/increment_number_product_in_cart/',[ShopCartController::class,'incrementOrDecrementElementInCart'])->name('increment_number_product_in_cart'); |
|
68 | - Route::post('/shop/delete_from_cart',[ShopCartController::class,'deleteFromCart'])->name('delete_from_cart'); |
|
69 | - Route::post('/shop/save_cache_details_order',[ShopCheckoutController::class,'saveDetailsInSession'])->name('save_cache_details_order'); |
|
70 | - Route::post('/shop/gotocheckout',[ShopShipmentController::class,'goToCheckout'])->name('shop.gotocheckout'); |
|
71 | - Route::post('/shop/pay',[ShopPaymentController::class,'pay'])->name('shop.pay'); |
|
72 | - Route::post('/shop/normalpayment',[ShopPaymentController::class,'normalPayment'])->name('shop.normalpayment'); |
|
66 | + Route::post('/shop/getcartproducts/', [ShopCartController::class, 'getCartProducts'])->name('getcartproducts'); |
|
67 | + Route::post('/shop/increment_number_product_in_cart/', [ShopCartController::class, 'incrementOrDecrementElementInCart'])->name('increment_number_product_in_cart'); |
|
68 | + Route::post('/shop/delete_from_cart', [ShopCartController::class, 'deleteFromCart'])->name('delete_from_cart'); |
|
69 | + Route::post('/shop/save_cache_details_order', [ShopCheckoutController::class, 'saveDetailsInSession'])->name('save_cache_details_order'); |
|
70 | + Route::post('/shop/gotocheckout', [ShopShipmentController::class, 'goToCheckout'])->name('shop.gotocheckout'); |
|
71 | + Route::post('/shop/pay', [ShopPaymentController::class, 'pay'])->name('shop.pay'); |
|
72 | + Route::post('/shop/normalpayment', [ShopPaymentController::class, 'normalPayment'])->name('shop.normalpayment'); |
|
73 | 73 | |
74 | 74 | |
75 | 75 | |
@@ -79,44 +79,44 @@ discard block |
||
79 | 79 | /***************** |
80 | 80 | *------GET------* |
81 | 81 | *****************/ |
82 | - Route::get('/admin/dashboard',[DashboardController::class,'page'])->name('admin.dashboard'); |
|
83 | - Route::get('/admin/categorie/',[AdminCategoryController::class,'page'])->name('admin.category.new'); |
|
84 | - Route::get('/admin/dettagli',[AdminDetailController::class,'page'])->name('admin.details'); |
|
85 | - Route::get('/admin/settings',[AdminSettingsController::class,'page'])->name('admin.settings'); |
|
82 | + Route::get('/admin/dashboard', [DashboardController::class, 'page'])->name('admin.dashboard'); |
|
83 | + Route::get('/admin/categorie/', [AdminCategoryController::class, 'page'])->name('admin.category.new'); |
|
84 | + Route::get('/admin/dettagli', [AdminDetailController::class, 'page'])->name('admin.details'); |
|
85 | + Route::get('/admin/settings', [AdminSettingsController::class, 'page'])->name('admin.settings'); |
|
86 | 86 | //products |
87 | - Route::get('/admin/prodotto/crea-prodotto',[AdminNewProductController::class,'page'])->name('admin.product.new'); |
|
88 | - Route::get('/admin/prodotti',[AdminProductsListController::class,'page'])->name('admin.product.list'); |
|
89 | - Route::get('/admin/prodotto/crea-singolo-prodotto',[AdminNewSingleProductController::class,'page'])->name('admin.new.single.product'); |
|
90 | - Route::get('/admin/prodotto-variante/{id_product}',[AdminNewProductVariationController::class,'page'])->name('admin.product.new.variante'); |
|
87 | + Route::get('/admin/prodotto/crea-prodotto', [AdminNewProductController::class, 'page'])->name('admin.product.new'); |
|
88 | + Route::get('/admin/prodotti', [AdminProductsListController::class, 'page'])->name('admin.product.list'); |
|
89 | + Route::get('/admin/prodotto/crea-singolo-prodotto', [AdminNewSingleProductController::class, 'page'])->name('admin.new.single.product'); |
|
90 | + Route::get('/admin/prodotto-variante/{id_product}', [AdminNewProductVariationController::class, 'page'])->name('admin.product.new.variante'); |
|
91 | 91 | //orders |
92 | - Route::get('/admin/ordini',[AdminOrdersController::class,'page'])->name('admin.orders.list'); |
|
93 | - Route::get('/admin/ordine/{order_id}',[AdminOrderDetailsController::class,'page'])->name('admin.order'); |
|
94 | - Route::get('/admin/clienti',[AdminClientsController::class,'page'])->name('admin.clients'); |
|
92 | + Route::get('/admin/ordini', [AdminOrdersController::class, 'page'])->name('admin.orders.list'); |
|
93 | + Route::get('/admin/ordine/{order_id}', [AdminOrderDetailsController::class, 'page'])->name('admin.order'); |
|
94 | + Route::get('/admin/clienti', [AdminClientsController::class, 'page'])->name('admin.clients'); |
|
95 | 95 | |
96 | 96 | |
97 | 97 | |
98 | 98 | /***************** |
99 | 99 | *-----POST------* |
100 | 100 | *****************/ |
101 | - Route::post('/admin/post/get/categories/tree',[AdminCategoryController::class,'getStructureCategories'])->name('admin.post.get.categories.tree'); |
|
102 | - Route::post('/admin/post/get/categories',[AdminCategoryController::class,'getCategories'])->name('admin.post.get.categories'); |
|
103 | - Route::post('/admin/post/create-new-category',[AdminCategoryController::class,'setNewCategory'])->name('admin.post.create.new.category'); |
|
101 | + Route::post('/admin/post/get/categories/tree', [AdminCategoryController::class, 'getStructureCategories'])->name('admin.post.get.categories.tree'); |
|
102 | + Route::post('/admin/post/get/categories', [AdminCategoryController::class, 'getCategories'])->name('admin.post.get.categories'); |
|
103 | + Route::post('/admin/post/create-new-category', [AdminCategoryController::class, 'setNewCategory'])->name('admin.post.create.new.category'); |
|
104 | 104 | |
105 | 105 | //details |
106 | - Route::post('/admin/post/create/detail',[AdminDetailController::class,'setNewDetail'])->name('admin.post.create.detail'); |
|
107 | - Route::post('/admin/post/get/details',[AdminDetailController::class,'getDetails'])->name('admin.post.get.details'); |
|
106 | + Route::post('/admin/post/create/detail', [AdminDetailController::class, 'setNewDetail'])->name('admin.post.create.detail'); |
|
107 | + Route::post('/admin/post/get/details', [AdminDetailController::class, 'getDetails'])->name('admin.post.get.details'); |
|
108 | 108 | |
109 | 109 | //configuration |
110 | - Route::post('/admin/post/create/configuration',[AdminConfigurationFieldController::class,'setNewConfiguration'])->name('admin.post.create.configuration'); |
|
111 | - Route::post('/admin/post/get/configuration',[AdminConfigurationFieldController::class,'getConfigurationFields'])->name('admin.post.get.configuration'); |
|
110 | + Route::post('/admin/post/create/configuration', [AdminConfigurationFieldController::class, 'setNewConfiguration'])->name('admin.post.create.configuration'); |
|
111 | + Route::post('/admin/post/get/configuration', [AdminConfigurationFieldController::class, 'getConfigurationFields'])->name('admin.post.get.configuration'); |
|
112 | 112 | |
113 | 113 | //product |
114 | - Route::post('/admin/prodotto/crea-prodotto',[AdminNewProductController::class,'createNewProduct'])->name('admin.post.product.new'); |
|
115 | - Route::post('/admin/prodotto/crea-variante-prodotto',[AdminNewProductVariationController::class,'createNewVariation'])->name('admin.post.product.variation.new'); |
|
116 | - Route::post('/admin/prodotto/crea-singolo-prodotto',[AdminNewSingleProductController::class,'createNewSingleProduct'])->name('admin.post.new.single.product'); |
|
114 | + Route::post('/admin/prodotto/crea-prodotto', [AdminNewProductController::class, 'createNewProduct'])->name('admin.post.product.new'); |
|
115 | + Route::post('/admin/prodotto/crea-variante-prodotto', [AdminNewProductVariationController::class, 'createNewVariation'])->name('admin.post.product.variation.new'); |
|
116 | + Route::post('/admin/prodotto/crea-singolo-prodotto', [AdminNewSingleProductController::class, 'createNewSingleProduct'])->name('admin.post.new.single.product'); |
|
117 | 117 | |
118 | 118 | |
119 | 119 | //refresh |
120 | - Route::get('/admin/update',[AdminUpdatePackageController::class,'update'])->name('admin.updatepackage'); |
|
120 | + Route::get('/admin/update', [AdminUpdatePackageController::class, 'update'])->name('admin.updatepackage'); |
|
121 | 121 | |
122 | 122 | }); |