Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

RonBPalmer's avatar

Class Architecture Question, base document with variations

I have a 15 year old personal business blog site that is a bit complicated with hundreds of posts and a significant number of pages. Its been on WordPress all this time. I recently started redesign in Astro for speed, changing direction to Laravel. There is a long legacy of WordPress plugin garbage as well so I'm scrubbing the data completely and restructuring it into something more sane than what WordPress does.

I'm a semi-retired large company IT Architect, so I tend to over-engineer towards scalability and flexibility. That said, I want to create a base document structure that will have various types of pages with differing kinds of content. I currently have a base document table, a meta-data table, and tables for each major variation. Currently, this is just page, post, definition, lesson, course, etc.

I'm looking for a unified model for each type of document. I want an interface for posts that draws from three tables minimum, and I want to abstract that model interface so that all my front-end retrieves and saves to a specific document model, without regard to the underlying plumbing. I'm thinking this is kind of like a Laravel model but more of a model of models.

I've been coding as a sideline since DOS 286 and basic, but my professional experience is more business and operational focused around designing and operating massive infrastructure. I know all the IT concepts deeply, but from a programmer's perspective, I will have significant gaps in implementation details.

Can someone please help me identify a path by which I can achieve this in Laravel. I will do the necessary research and learning but would prefer to avoid going down wrong paths. I will ultimately be using Livewire, filament, and a security package but I'm also doing this as a learning exercise and want to do a lot in basic Laravel first and maybe port things over as I get closer to production.

In my mind, I need a model architecture, but that may not directly align with the way Laravel sees Models. How can I best create a common interface to multiple Laravel Models and Controllers so that when I work with posts, I get a single representation of every available post element, and likewise, when I work with a definition and related pages, I have a single representation of that. Each will have methods, i.e. a definition will have a short a short entry that I call as a snippet for things like popovers and multiple elements to produce something like a Wikipedia article on the topic.

Essentially, everything will begin with a common base document for very basic things like routing with an intermediate level for specific kinds of documents geared towards the presentation layer.

1 like
1 reply
juanborras's avatar

Hey!

Looks like a very interesting project. I would suggest you take a peek at filamentphp...

I would suggest you define what you want, maybe an ER model, some lifecycle diagrams for your documents and a few use cases so you can grab a better picture of what you try to accomplish? After that deep dive into Eloquent...

Please or to participate in this conversation.