<?php

namespace App\Http\Livewire;

use App\Models\Eklentiler;
use Livewire\Component;
use Cart;

class Scriptdetayeklenti extends Component
{
    public $idsi;

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


    public function render()
    {

        $ozeleklentiler=Eklentiler::where([
            ['script_id', $this->idsi],
            ['durum', 1]
        ])->get();




        return view('livewire.scriptdetayeklenti',compact('ozeleklentiler'));
    }


    public function addeklenti($product_id,$product_baslik,$product_fiyat)
    {
        Cart::add($product_id,$product_baslik,1,$product_fiyat,['product_type' => 3])->associate('\App\Models\Eklentiler');
        $this->emitTo('sepet','refreshComponent');
        $this->emitTo('sepeticonu','refreshComponent');

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


    }




}
