first commit
This commit is contained in:
53
app/Http/Controllers/StaterkitController.php
Normal file
53
app/Http/Controllers/StaterkitController.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Models\Transaction;
|
||||
use App\Models\User;
|
||||
use App\Models\Video;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class StaterkitController extends Controller
|
||||
{
|
||||
// home
|
||||
public function home()
|
||||
{
|
||||
$breadcrumbs = [
|
||||
['link' => "admin/dashboard", 'name' => "Dashboard"]
|
||||
];
|
||||
|
||||
$admin = Auth::user();
|
||||
$students = User::where('role', 'STUDENT')->count();
|
||||
$activeStudents = User::where('role', 'STUDENT')->where('status', 1)->count();
|
||||
$categories = Category::count();
|
||||
$videos = Video::count();
|
||||
$credits = Transaction::where('type', 'credit')->whereMonth('created_at', Carbon::now()->month)->sum('amount');
|
||||
$debits = Transaction::where('type', 'debit')->whereMonth('created_at', Carbon::now()->month)->sum('amount');
|
||||
$earnings = $credits - $debits;
|
||||
|
||||
return view('content.home', [
|
||||
'breadcrumbs' => $breadcrumbs,
|
||||
'adminDetails' => $admin,
|
||||
'students' => $students,
|
||||
'categories' => $categories,
|
||||
'videos' => $videos,
|
||||
'earnings' => $earnings,
|
||||
'activeStudents' => $activeStudents,
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
public function toggleTheme()
|
||||
{
|
||||
$theme = session()->has('theme') ? session()->get('theme') : 'light';
|
||||
if ($theme == 'light') {
|
||||
session()->put('theme', 'dark');
|
||||
} else {
|
||||
session()->put('theme', 'light');
|
||||
}
|
||||
return response()->json(['status' => true, 'message' => 'Theme updated in config']);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user