Skip to content

Commit

Permalink
Merge pull request #80 from andes2912/feature/murid
Browse files Browse the repository at this point in the history
Bug fix data statistik
  • Loading branch information
andes2912 authored May 29, 2022
2 parents 4192875 + ba5ed6a commit 3a4aa1b
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,34 @@ public function index()
}
// DASHBOARD MURID \\
elseif ($role == 'Murid') {
$auth = Auth::id();

$event = Events::where('is_active','0')->first();
$lateness = Borrowing::with(['members' => function($q){
$q->where('user_id', Auth::id());
}])
$lateness = Borrowing::with('members')
->when(isset($auth), function($q) use($auth){
$q->whereHas('members', function($a) use($auth){
switch ($auth) {
case $auth:
$a->where('user_id', Auth::id());
break;
}
});
})
->whereNull('lateness')
->count();

$pinjam = Borrowing::with(['members' => function($q){
$q->where('user_id', Auth::id());
}])->count();

$pinjam = Borrowing::with('members')
->when(isset($auth), function($q) use($auth){
$q->whereHas('members', function($a) use($auth){
switch ($auth) {
case $auth:
$a->where('user_id', Auth::id());
break;
}
});
})
->count();

return view('murid::index', compact('event','lateness','pinjam'));

Expand Down

0 comments on commit 3a4aa1b

Please sign in to comment.