コード例 #1
0
ファイル: PostTest.php プロジェクト: bertog/eengineering-web
 /** @test */
 public function retrieve_only_the_published_post()
 {
     factory('App\\Post')->create(['published' => '2015-01-01']);
     factory('App\\Post')->create(['published' => '2015-01-01']);
     $notPublished = factory('App\\Post')->create(['published' => '2030-12-31']);
     $this->assertCount(2, Post::PublishedPost()->get());
 }
コード例 #2
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $posts = Post::PublishedPost()->get();
     return view('post.index', compact('posts'));
 }