Laravel (4.2): Single table inheritance for Eloquent

Written by on August 21, 2014 in Development

Originally I wanted to publish this article when Laravel 4.2 was only in development but it is out for a while now so I’m here to present my trait for this particular issue. Whilst the title may not be straight forward, here is the thing with more than 3 words: Multiple models sharing one table, auto-filtering queries based on column value. If you are familiar with WordPress you probably know that there is only one table with all the pages, posts, attachments and “custom post types“. This article is not about explaining all the little details, it’s for more advanced developers who can grab my code snippet. I assume you already know Laravel, Eloquent and PHP5.4.

2 comments Read more