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

bogdy's avatar
Level 10

Laravel, create a post with different content

I have a question. I don't want you to give me the final solution, just a piece of advice about the smartest solution to say I make a blog. There are three types of posts For example: a post can, be a video post and the create form has file input, title etc etc a post can be a content post and the create form it has a few other inputs a post ca be Questions quiz and the register form has other types of inputs what would be an intelligent solution for this? changing form fields based on model selection? can anyone recommend me something ? DB schema or some helpful information Thanks in Advance!

0 likes
4 replies
Tjyoung's avatar

what I understand from your question is, you are trying to create a post with three different types with selected fields, so with my experience I would go with single DB table with two different fields, first will have post type (Video, Content,....) and second would be fields with type JSON which can contain all kind of fields and information. Not the best solution but I think its one way to look at.

lalitesh's avatar
lalitesh
Best Answer
Level 4

I would suggest the following the DB schema to make a blog like the one you need to:

Table post_types

id: PK
title

Table post_types_meta_fields

post_type_id (Foreign key to post_types:id field )
field_type: File, input, textarea etc
is_required
default_value
---
---

Table posts

id: PK
post_type_id (Foreign key to post_types:id field )
---
other fields
---
---

In this way, you can have n number of custom fields, specific to a post type. post_types and post_types_meta_fields can have many to many relations as there could be some common fields for more than one post type.

Hope it helps.

Please or to participate in this conversation.