<?php

namespace App\Http\Livewire;

use Livewire\Component;
use Cart;

class Indexpaket1 extends Component
{


    public $paket;

    public function mount($paket)
    {
        $this->paket = $paket;
    }


    public function render()
    {
        return view('livewire.indexpaket1');
    }


    public function addToCart($product_id,$product_baslik,$product_fiyat)
    {
        Cart::add($product_id,$product_baslik,1,$product_fiyat,['product_type' => 2])->associate('\App\Models\Paket_urunler');


        $this->emitTo('sepeticonu','refreshComponent');

        $swalData = [
            'type' => 'success',
            'title' => 'Başarılı',
            'message' => 'Sepete Başarıyla Eklenmiştir, Yönleniyorsuz',
        ];
        $this->dispatchBrowserEvent('islembasarili', $swalData);

        return redirect()->route('cart');

    }
}
