/** * Show the application welcome screen to the user. * * @return Response */ public function index() { $about = array(''); //$news = array(); $articles = article::all(); foreach ($articles as $article) { //echo $article->type; } $about = \App\article::where('type', '=', 'about')->first(); return view('home')->with('credential', $this->credential)->with('about', $about); }
public function get_articles() { if (Auth::User()->admin) { $requests = article::all(); } else { $requests = Auth::User()->articles; } $result = []; foreach ($requests as $request) { $result[] = [$request->id, $request->user->name, $request->title, $request->created_at->toDateTimeString(), $request->published_at->toDateTimeString(), ""]; } return ["data" => $result]; }
public function index() { $user = Auth::user(); if (!empty($user)) { echo $user->name; } /** * 9/14 現在是透過再次find(`user`)取得user資料,要找其他方式做Join關聯查詢 * 9/21 觀看全部文章,僅可編輯自己文章 */ $m_article = article::all(); $articles = array(); foreach ($m_article as $k => $v) { $articles[$k]['id'] = $v->id; $articles[$k]['name'] = $v->name; $articles[$k]['content'] = $v->content; $articles[$k]['updated_at'] = $v->updated_at; $articles[$k]['user_id'] = $v->user_id; $articles[$k]['user_mail'] = user::find($v->user_id)['account']; } return view('Mars.article.index')->withArticles($articles)->withTitle(self::$title)->withFun(self::$fun)->withUser($user); }
public function articleTest() { $data = array('article' => article::all()); return View('articleTest', $data); }