<?php

namespace App\Livewire\ChartBuilder;

use Livewire\Component;
use App\Models\ChartBuilder;

class Index extends Component
{
    public function delete($id)
    {
        
        $chart = ChartBuilder::findOrFail($id);
        $chart->delete();

        session()->flash('success', 'Chart deleted successfully!');
        // $this->dispatch('$refresh');
        return $this->redirectRoute('chart-builder', navigate: true);
    }
    public function render()
    {
        $charts = ChartBuilder::where('status',1)->get();
        return view('livewire.chart-builder.index',[
            "charts" => $charts
        ]);
    }
}
