摘要： 本文讲的是Jon LeMaitre: Separation of Concerns with Laravel’s Eloquent (Series)， Jon LeMaitrehas written up a series of posts talking about effective separation of concerns using Eloquent, the
Jon LeMaitrehas written up a series of posts talking about effective separation of concerns using Eloquent, the database access component of the Laravel framework. His goal is to show you how makes use of the library and keep your application both maintainable and readable.
Eloquent (and by extension, Laravel) is often criticized because of its ActiveRecord ORM implementation, and that DataMapper produces a cleaner, more maintainable architecture in the long run. [...] This combination of behaviors crammed into a single object in itself is not the problem (in fact, it’s a wonderful asset), the problem is in how you make use of those behaviors throughout your application. You can be sloppy with them, or you can be tidy with them.
He starts with the "sloppy approach" where different methods of accessing the objects (and their data) are spread all across the application. He counters this with the tidy approach that makes use of "persistence-agnostic 'POPOs'" to hide the logic behind repositories. In the second part of the serieshe starts in and puts this idea into practice, using a simple "Member" table and model and repository classes to abstract the logic. Finally, in part threehe gets into some more extended functionality for the repositories approach: handling collections, relations, eager loading and schema changes.
|计算机网络概念问题，求帮助||Laravel Eloquent下wit...||现在写 PHP，你应该知道这些|
|...is 00:66:77:88:99:006. the netmask is 255.255.255.0...||假如我们现在有两张表：user 和 posts，每个 User 可以拥有多个 Posts，而每一篇 Post...||...控制（不带 Action 后缀或前缀的），有一个好用的 ORM (Eloquent)，好用的模板引擎 ...|