<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class DataWAController extends Controller
{
    public function index()
    {
        $file = storage_path('app/public/dataWA_matang_dengan_klasifikasi.csv');
        $data = $this->readCsv($file);

        return view('dataWA', ['data' => $data]);
    }

    private function readCsv($file)
    {
        $rows = [];
        if (($handle = fopen($file, 'r')) !== false) {
            while (($data = fgetcsv($handle, 1000, ',')) !== false) {
                $rows[] = $data;
            }
            fclose($handle);
        }
        return $rows;
    }

}
