File manager - Edit - /var/www/payraty/accounting_main/app/Http/Controllers/DashboardController.php
Back
<?php namespace App\Http\Controllers; use App\Models\BalanceSheet; use App\Models\BankAccount; use App\Models\Bill; use App\Models\Goal; use App\Models\Invoice; use App\Models\Order; use App\Models\Payment; use App\Models\Plan; use App\Models\ProductServiceCategory; use App\Models\ProductServiceUnit; use App\Models\Revenue; use App\Models\Tax; use App\Models\Utility; use App\Models\User; use App\Models\ProductService; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\DB; class DashboardController extends Controller { /** * Create a new controller instance. * * @return void */ public function __construct() { // } /** * Show the application dashboard. * * @return \Illuminate\Contracts\Support\Renderable */ public function index() { $data['latestIncome'] = Revenue::where('created_by', '=', \Auth::user()->creatorId())->orderBy('id', 'desc')->limit(5)->get(); $data['latestExpense'] = Payment::where('created_by', '=', \Auth::user()->creatorId())->orderBy('id', 'desc')->limit(5)->get(); $productServices = ProductService::all(); // Adjust query as needed $incomeCategory = ProductServiceCategory::where('created_by', '=', \Auth::user()->creatorId())->where('type', '=', 'income')->get(); $inColor = array(); $inCategory = array(); $inAmount = array(); for ($i = 0; $i < count($incomeCategory); $i++) { $inColor[] = $incomeCategory[$i]->color; $inCategory[] = $incomeCategory[$i]->name; $inAmount[] = $incomeCategory[$i]->incomeCategoryRevenueAmount(); } $data['incomeCategoryColor'] = $inColor; $data['incomeCategory'] = $inCategory; $data['incomeCatAmount'] = $inAmount; $expenseCategory = ProductServiceCategory::where('created_by', '=', \Auth::user()->creatorId())->where('type', '=', 'expense')->get(); $exColor = array(); $exCategory = array(); $exAmount = array(); for ($i = 0; $i < count($expenseCategory); $i++) { $exColor[] = $expenseCategory[$i]->color; $exCategory[] = $expenseCategory[$i]->name; $exAmount[] = $expenseCategory[$i]->expenseCategoryAmount(); } $data['expenseCategoryColor'] = $exColor; $data['expenseCategory'] = $exCategory; $data['expenseCatAmount'] = $exAmount; $data['incExpBarChartData'] = \Auth::user()->getincExpBarChartData(); $data['incExpLineChartData'] = \Auth::user()->getIncExpLineChartDate(); $data['currentYear'] = date('Y'); $data['currentMonth'] = date('M'); $constant['taxes'] = Tax::where('created_by', \Auth::user()->creatorId())->count(); $constant['category'] = ProductServiceCategory::where('created_by', \Auth::user()->creatorId())->count(); $constant['units'] = ProductServiceUnit::where('created_by', \Auth::user()->creatorId())->count(); $constant['bankAccount'] = BankAccount::where('created_by', \Auth::user()->creatorId())->count(); $data['constant'] = $constant; $data['bankAccountDetail'] = BankAccount::where('created_by', '=', \Auth::user()->creatorId())->get(); $data['recentInvoice'] = Invoice::where('created_by', '=', \Auth::user()->creatorId())->orderBy('id', 'desc')->limit(5)->get(); $data['weeklyInvoice'] = \Auth::user()->weeklyInvoice(); $data['monthlyInvoice'] = \Auth::user()->monthlyInvoice(); $data['recentBill'] = Bill::where('created_by', '=', \Auth::user()->creatorId())->orderBy('id', 'desc')->limit(5)->get(); $data['weeklyBill'] = \Auth::user()->weeklyBill(); $data['monthlyBill'] = \Auth::user()->monthlyBill(); $data['goals'] = Goal::where('created_by', '=', \Auth::user()->creatorId())->where('is_display', 1)->get(); $users = User::find(\Auth::user()->creatorId()); $profile = \DB::table('profiles')->where('user_id', \Auth::user()->id)->first(); return view('dashboard.index', $data, compact('users', 'productServices', 'profile')); } public function getOrderChart($arrParam) { $arrDuration = []; if ($arrParam['duration']) { if ($arrParam['duration'] == 'week') { $previous_week = strtotime("-2 week +1 day"); for ($i = 0; $i < 14; $i++) { $arrDuration[date('Y-m-d', $previous_week)] = date('d-M', $previous_week); $previous_week = strtotime(date('Y-m-d', $previous_week) . " +1 day"); } } } $arrTask = []; $arrTask['label'] = []; $arrTask['data'] = []; foreach ($arrDuration as $date => $label) { $data = Order::select(\DB::raw('count(*) as total'))->whereDate('created_at', '=', $date)->first(); $arrTask['label'][] = $label; $arrTask['data'][] = $data->total; } return $arrTask; } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.30 | Generation time: 4.08 |
proxy
|
phpinfo
|
Settings