/**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     // return view('articles.lists', array(
     //     'time' => date('Y/m/d H:i:s',time()),
     //     'name' => '<span style="color : red">longlong</span>',
     //     'test' => 'test',
     //     'arrs' => array('arr1', 'arr2')
     //     ));
     // $articles = Article::all();
     if (!Auth::user()) {
         return redirect('/auth/login');
     }
     $user = Auth::user();
     $articles = Article::latest()->published()->where('user_id', '=', $user->id)->get();
     return view('articles.index', compact('articles'));
     //return $articles;
 }
Example #2
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $articles = Article::latest('published_at')->published()->get();
     return view('articles.index', ['title' => '文章', 'articles' => $articles]);
 }