Created
August 29, 2014 09:18
-
-
Save coreymcmahon/4d332495f29f51dad64c to your computer and use it in GitHub Desktop.
Using the Repository Pattern - example 2 - http://www.slashnode.com/why-use-repository-pattern/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class PostController | |
{ | |
public function index() | |
{ | |
$posts = Post::where('date', '>', Carbon::now()->subDays(7))->get(); | |
return View::make('users.show', compact('posts')); | |
} | |
// ... | |
} | |
class UserController | |
{ | |
public function show($user_id) | |
{ | |
$posts = Post::where('date', '>', Carbon::now()->subDays(7)) | |
->where('user_id', $user_id)->get(); | |
return View::make('users.show') | |
->with('users', User::find($user_id)) | |
->with('posts', $posts); | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment