Beispiel #1
0
 public function updateBasicStatistics($userId, $item, $value = 1)
 {
     $statistics = CustomerStatistics::where('customer_id', $userId)->first();
     if (!$statistics) {
         $statistics = new CustomerStatistics();
         $statistics->customer_id = $userId;
     }
     /*if>*/
     $statistics->{$item} += $value;
     $statistics->save();
 }
 public function statistics()
 {
     $customer = \Helper::getCustomer();
     if ($customer->type->type_en == AppConstant::CUSTOMER_ENTERPRISE) {
         $enterpriseCommodityStatistics = EnterpriseCommodityStatistics::getAllStatistics();
         $enterpriseArticleStatistics = EnterpriseArticleStatistics::getAllStatistics();
         //            $enterpriseBasicStatistics = EnterpriseBasicStatistics::where('date', Carbon::now()->format('Y-m-d'))->get()->toArray();
         $enterpriseBasicStatistics = EnterpriseBasicStatistics::getAllStatistics();
         return view('personal.enterprise', ['data' => ['enterprise_commodity_statistics' => EnterpriseCalculator::commodity(), 'enterprise_article_statistics' => $enterpriseArticleStatistics, 'enterprise_basic_statistics' => EnterpriseCalculator::basic()]]);
     } else {
         $customerCommodityStatistics = CustomerCommodityStatistics::getStatisticsByCustomerID($customer->id);
         $customerArticleStatistics = CustomerArticleStatistics::getStatisticsByCustomerID($customer->id);
         $customerStatistics = CustomerStatistics::where('customer_id', $customer->id)->get()->toArray();
         return view('personal.customer', ['data' => ['customer_commodity_statistics' => $customerCommodityStatistics, 'customer_article_statistics' => $customerArticleStatistics, 'customer_statistics' => $customerStatistics, 'doctor_type' => $customer->doctorType(), 'monthly_invite_count' => (new CustomerInvitationCounter($customer))->getMonthlyCount(), 'focus_count' => $customer->focus_count, 'register_count' => $customer->register_count, 'questionnaire_count' => $customer->questionnaire_count]]);
     }
 }