Add all files
This commit is contained in:
31
app/Livewire/Components/Cart.php
Normal file
31
app/Livewire/Components/Cart.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Components;
|
||||
|
||||
use App\Classes\Cart as ClassesCart;
|
||||
use App\Livewire\Component;
|
||||
use Livewire\Attributes\On;
|
||||
|
||||
class Cart extends Component
|
||||
{
|
||||
public $cartCount;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->cartCount = ClassesCart::get()->count();
|
||||
if (ClassesCart::get()->isEmpty()) {
|
||||
$this->skipRender();
|
||||
}
|
||||
}
|
||||
|
||||
#[On('cartUpdated')]
|
||||
public function onCartUpdated()
|
||||
{
|
||||
$this->cartCount = ClassesCart::get()->count();
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('components.cart');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user