���ѧۧݧ�ӧ�� �ާ֧ߧ֧էا֧� - ���֧էѧܧ�ڧ��ӧѧ�� - /home/zhaagvlk/web.zhaap.com/app__1b5d5ff/Http/Controllers/DashboardController.php
���ѧ٧ѧ�
<?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 Illuminate\Support\Facades\Auth; 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() { if (Auth::check()) { if (\Auth::user()->type == 'super admin') { $user = \Auth::user(); $user['total_user'] = $user->countCompany(); $user['total_paid_user'] = $user->countPaidCompany(); $user['total_orders'] = Order::total_orders(); $user['total_orders_price'] = Order::total_orders_price(); $user['total_plan'] = Plan::total_plan(); $user['most_purchese_plan'] = (!empty(Plan::most_purchese_plan()) ? Plan::most_purchese_plan()->total : 0); $chartData = $this->getOrderChart(['duration' => 'week']); return view('dashboard.super_admin', compact('user', 'chartData')); } else { if (\Auth::user()->can('show dashboard')) { $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(); $incomeCategory = ProductServiceCategory::where('created_by', '=', \Auth::user()->creatorId())->where('type', '=', 1)->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', '=', 2)->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(); } else { $data = []; } $users = User::find(\Auth::user()->creatorId()); $plan = Plan::find($users->plan); if(!empty($plan)){ if ($plan->storage_limit > 0) { $storage_limit = ($users->storage_limit / $plan->storage_limit) * 100; } else { $storage_limit = 0; } } else{ return view('dashboard.index', $data, compact('users','plan')); } return view('dashboard.index', $data, compact('users', 'plan', 'storage_limit')); } } else { if (!file_exists(storage_path() . "/installed")) { header('location:install'); die; } else { $settings = Utility::settings(); if ($settings['display_landing_page'] == 'on' && \Schema::hasTable('landing_page_settings')) { return view('landingpage::layouts.landingpage'); } else { return redirect('login'); } } } } 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.1.34 | ���֧ߧ֧�ѧ�ڧ� ����ѧߧڧ��: 0.1 |
proxy
|
phpinfo
|
���ѧ����ۧܧ�