namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; use Illuminate\Http\Request; use App\Models\User; use App\Models\Transaction; use App\Models\Loan; class ReportController extends Controller { // ૪. મેમ્બર પ્રોફાઈલ સર્ચ પેજ public function searchPage(Request $request) { $member = null; $activeLoan = null; $totalPaid = 0; $totalRemaining = 0; if ($request->has('q')) { $query = $request->q; $member = User::with(['loans.transactions']) ->where('role', 'member') ->where('name', 'LIKE', "%{$query}%") ->orWhere('mobile', 'LIKE', "%{$query}%") ->first(); if ($member && $member->loans->count() > 0) { $activeLoan = $member->loans->where('status', 'active')->first(); if ($activeLoan) { $totalPaid = $activeLoan->transactions->sum('amount'); $totalRemaining = $activeLoan->total_payable - $totalPaid; } } } return view('admin.search', compact('member', 'activeLoan', 'totalPaid', 'totalRemaining')); } // ૭. ડેશબોર્ડ ફૂલ વિગત સાથે public function dashboard() { $totalInvestment = Loan::sum('principal_amount'); $totalCollection = Transaction::sum('amount'); $totalActiveLoans = Loan::where('status', 'active')->count(); $todayCollection = Transaction::whereDate('payment_date', today())->sum('amount'); return view('admin.dashboard', compact('totalInvestment', 'totalCollection', 'totalActiveLoans', 'todayCollection')); } }