Once you start actually building something with Laravel, it’s easy to find yourself repeatedly typing the same code when you fetch relationships. This article shows you a centralised approach using scopes.
Imagine you have models for
Post and a relationship between the two —
Blog hasMany Post.
Post has a
datetime field called
published_at — but your posts aren’t necessarily in order of date published, as some of them take longer to proof than others.
Across your site, you need to show the 3 most recently-published posts for each blog. Eloquent makes this easy:
So being realistic, only Labour and the Tories have any chance of getting in — so I’ll limit my comments to those. You’ll soon see that I’m intending to vote Labour — regardless, I’ve tried to read a balanced set of articles and question everything.
Both the Tories and Labour are committing themselves to going ahead with Brexit negotiations without an option of a second referendum — so we can skip over that and focus on the fact that many of our social systems are struggling. …