TIF_NGANJUK_E41220949/app/Http/Controllers/IndexController.php

34 lines
853 B
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Sampah;
use App\Models\KategoriTps;
use App\Models\LokasiTps;
use Illuminate\Http\Request;
class IndexController extends Controller
{
public function index()
{
$sampah = Sampah::orderBy('tahun', 'desc')->first();
$kategoriTps = KategoriTps::orderBy('id_kategori_tps')->get();
$tps = LokasiTps::all(); // disamakan dengan yang dipakai di view
$jumlahTps = LokasiTps::where('kategori_tps_id', 1)->count();
$jumlahTps3r = LokasiTps::where('kategori_tps_id', 2)->count();
$jumlahTpa = LokasiTps::where('kategori_tps_id', 3)->count();
return view('user.index', compact(
'sampah',
'kategoriTps',
'tps',
'jumlahTps',
'jumlahTps3r',
'jumlahTpa'
));
}
}