Skip to content

Instantly share code, notes, and snippets.

@coreymcmahon
Created August 29, 2014 09:13
Show Gist options
  • Save coreymcmahon/27564bd2daf9207b00f1 to your computer and use it in GitHub Desktop.
Save coreymcmahon/27564bd2daf9207b00f1 to your computer and use it in GitHub Desktop.
Using the Repository Pattern - example 1 - http://www.slashnode.com/why-use-repository-pattern/
<?php
class PostRepository
{
public function getRecent()
{
return Post::where('date', '>', Carbon::now()->subDays(7))->get();
}
public function getRecentFor($user_id)
{
return Post::where('date', '>', Carbon::now()->subDays(7))
->where('user_id', $user_id)->get();
}
//...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment