@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | |
| 6 | 6 | class ShopUserController extends Controller |
| 7 | 7 | { |
| 8 | - public function page(){ |
|
| 8 | + public function page() { |
|
| 9 | 9 | $user = Auth::user(); |
| 10 | 10 | $piva = $user->piva; |
| 11 | 11 | $rag_soc = $user->company; |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | $province = $user->province; |
| 19 | 19 | $city = $user->city; |
| 20 | 20 | $cap = $user->cap; |
| 21 | - return view('mongicommerce.pages.user_settings',compact('piva', |
|
| 21 | + return view('mongicommerce.pages.user_settings', compact('piva', |
|
| 22 | 22 | 'rag_soc', |
| 23 | 23 | 'first_name', |
| 24 | 24 | 'last_name', |
@@ -135,7 +135,7 @@ |
||
| 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 | 140 | switch ($type){ |
| 141 | 141 | case 'iban': |
@@ -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; |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | $check_order = Order::orderBy('created_at','desc')->first(); |
| 42 | 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()); |
@@ -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) |
@@ -7,12 +7,12 @@ |
||
| 7 | 7 | |
| 8 | 8 | class ShopLogoutController extends AuthenticatedSessionController |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * Destroy an authenticated session. |
|
| 12 | - * |
|
| 13 | - * @param \Illuminate\Http\Request $request |
|
| 14 | - * @return \Illuminate\Http\RedirectResponse |
|
| 15 | - */ |
|
| 10 | + /** |
|
| 11 | + * Destroy an authenticated session. |
|
| 12 | + * |
|
| 13 | + * @param \Illuminate\Http\Request $request |
|
| 14 | + * @return \Illuminate\Http\RedirectResponse |
|
| 15 | + */ |
|
| 16 | 16 | public function destroy(Request $request) |
| 17 | 17 | { |
| 18 | 18 | Auth::guard('web')->logout(); |
@@ -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'); |