Skip to content

Commit 49b6146

Browse files
committed
Fix session
1 parent 2fa52dc commit 49b6146

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

app/Models/Cart.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ public function __construct()
1313
$this->items = collect();
1414

1515
if (session()->has('cart')) {
16-
$this->items = session('cart')->items;
16+
$this->items = session('cart');
1717
}
1818
}
1919

2020
public function add($product, $key)
2121
{
2222
$this->items->put($key, $product);
23-
session()->put('cart', $this);
23+
session()->put('cart', $this->items);
2424
}
2525

2626
public function totalPrice()

app/Providers/AppServiceProvider.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
namespace App\Providers;
44

55
use App\Contracts\PaymentContract;
6+
use App\Models\Cart;
67
use App\Models\StripePayment;
8+
use Illuminate\Support\Facades\View;
79
use Illuminate\Support\ServiceProvider;
810

911
class AppServiceProvider extends ServiceProvider
@@ -15,7 +17,7 @@ class AppServiceProvider extends ServiceProvider
1517
*/
1618
public function register()
1719
{
18-
$this->app->bind(PaymentContract::class, StripePayment::class);
20+
//$this->app->bind(PaymentContract::class, StripePayment::class);
1921
}
2022

2123
/**
@@ -25,6 +27,10 @@ public function register()
2527
*/
2628
public function boot()
2729
{
28-
//
30+
$this->app->bind('App\Contracts\PaymentContract', 'App\Models\StripePayment');
31+
32+
View::composer('layouts.app', function ($view) {
33+
$view->with(['cart' => new Cart()]);
34+
});
2935
}
3036
}

0 commit comments

Comments
 (0)