public static function getStatisticsByCustomerID($customerID) { $details = CustomerArticleStatistics::where('customer_id', $customerID)->get(); if ($details) { $details = $details->toArray(); } else { $details = []; } foreach ($details as &$detail) { $detail['article_type'] = ArticleType::find($detail['article_type_id'])->toArray(); } return $details; }
public static function getTodayStatistics() { $statisticsDetails = EnterpriseArticleStatistics::where('date', Carbon::now()->format('Y-m-d'))->get(); if ($statisticsDetails) { $statisticsDetails = $statisticsDetails->toArray(); } else { $statisticsDetails = []; } foreach ($statisticsDetails as &$details) { $details['article_type'] = ArticleType::find($details['article_type_id'])->toArray(); } return $statisticsDetails; }
public function category(Request $request) { $type = ArticleType::where('type_en', $request->input('type'))->first(); if (!$type) { abort(404); } /*if>*/ $typeArticles = Article::where('type_id', $type->id)->orderBy('count', 'desc')->get(); if (!$typeArticles) { abort(404); } /*if>*/ return view('education.article-category', ['title' => $type->type_ch, 'articles' => $typeArticles]); }
/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { return view('backend.article.create')->with(['types' => ArticleType::all()]); }
/** * 获取新闻分类 */ public function articleType() { $types = ArticleType::all()->toArray(); return return_rest('1', compact('types'), '获取文章类型'); }
/** * @return \yii\db\ActiveQuery */ public function getArticleType() { return $this->hasOne(ArticleType::className(), ['type_id' => 'article_type']); }