<?php

namespace App\Http\Controllers\Kasir;

use App\Http\Controllers\Controller;
use App\Models\Pesanan;
use App\Models\Produk;
use Illuminate\Http\Request;

class Menu extends Controller
{
    public function index()
    {
        return view('pages.menu.index');
    }

    public function getDataMenu()
    {
        $data = Produk::with(['kategori_produk'])->get();
        $nomor = 1;

        return $datatables = datatables()
            ->of($data)
            ->addColumn('nomor', function ($data) use (&$nomor) {
                return $nomor++;
            })
            ->addColumn('kategori_produk', function ($data) {
                return $data->kategori_produk->nama_kategori_produk;
            })
            ->addColumn('ubah', function ($data) {
                return '<div class="btn-group">
                            <a href="javascript:void(0)" onclick="print(\'' . $data->id . '\')"><span class="btn btn-xs btn-success"><i class="fas fa-print"></i></span></a>
                        </div>';
            })
            ->rawColumns(['nomor', 'kode_produk', 'ubah'])
            ->make(true);
    }
}
