Home Controller
materi 6user_3285855
php
2 years ago
1.0 kB
5
Indexable
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Models\Keuangan; use App\Models\Kategori; use App\Models\User; use PDF; class HomeController extends Controller { /** * Create a new controller instance. * * @return void */ public function __construct() { $this->middleware('auth'); } /** * Show the application dashboard. * * @return \Illuminate\Contracts\Support\Renderable */ public function index() { $keuangan = Keuangan::all(); $pdf = PDF::loadview('dashboard.report', ['keuangan' => $keuangan]); return $pdf->stream(); } public function dashboard() { $uang_masuk = Keuangan::where('jenis', 0)->sum('jumlah'); $uang_keluar = Keuangan::where('jenis', 1)->sum('jumlah'); $kategori = Kategori::count(); $pengguna = User::count(); return view('dashboard.index', compact([ 'uang_masuk', 'uang_keluar', 'kategori', 'pengguna', ])); } }
Editor is loading...
Leave a Comment