<?php

namespace App\Http\Controllers\Admin\Service;

use App\DataTables\Admin\Service\LogDataTable;
use App\Http\Controllers\Controller;
use App\Models\ServiceLog;
use Illuminate\Http\Request;

class LogController extends Controller {
    public function list(LogDataTable $dataTable) {
        $components['breadcrumb'] = (object) [
			'first' => 'Log Gagal',
			'second' => 'Layanan'
		];
        $components['created_at'] = ServiceLog::selectRaw('DATE(created_at) AS created_at')->distinct()->latest('created_at')->get();
        $components['users'] = ServiceLog::distinct()->latest('user_id')->get(['user_id']);
        $components['services'] = ServiceLog::distinct()->latest('service_id')->get(['service_id']);
        $components['providers'] = ServiceLog::distinct()->latest('provider_id')->get(['provider_id']);
        return $dataTable->render('admin.service.log.list', $components);
    }
}
