What do you mean by Repositories instead of Models ?
class UserRepository{
public function getPopularWomen(){
return User::popular()->women()->orderBy('created_at')->get();
}
}
:)
That could be useful for testing (by injecting repositories in the controllers). But repositories are often associated with the data mapper design pattern, which has a different way of handling data than active record (Eloquent's design pattern). Take a look at Doctrine if you're interested in the data mapper pattern.
It's not difficult. I just do something like this: https://gist.github.com/thepsion5/eb0af8b3040eaa0b219e
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community