コード例 #1
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($date, $slug)
 {
     // createFromFormat ensures that the date string in the URL is the
     // correct format; we don't want multiple date formats being
     // accepted. startOfDay is necessary to ensure that the
     // where clause two lines down executes properly.
     $date = Carbon::createFromFormat('Y-m-d', $date)->startOfDay();
     $article = Article::where('pubdate', $date)->where('slug', $slug)->firstOrFail();
     $draft = $article->latestDraft();
     $authors = $article->authors;
     return view('article', compact('article', 'draft', 'authors'));
 }