Support the ongoing development of Laravel.io →
Database Eloquent Architecture

I have a polymorphic relationship issue that i'm trying to solve. But i dont know how to go about it or if im even on the right track. I will keep it as short and simple as possible.

I'm trying to create settings for a very dynamic system that i'm working on. This is what i have so far.

settings (definition settings)
	id
	name

setting_values (hold the setting values with a poly relationship to its owner)
	id
	value
	setting_id
	owner_id
	owner_type

clients (definition clients, clients are setting value owners)
	id
	name

users (definition users, clients are setting value owners)
	id
	name

categories (definition categories)
	id
	name

category_client (pivot table, holds which clients have which categories)
	id
	category_id
	client_id

category_user (pivot table, holds which users have which categories)
	id
	category_id
	user_id

So this is my structure (simplified), now to my question. I want to be able to set a setting value for a specific client, on a specific category. But this should of course not be inherited by the users or other clients.

How do i make a category_client (pivot table) a owner_type? Or is that even the right way to go about it? What am i missing here? As far as i can see i have a many-to-many-to-many relationship.

Hope somebody can point me on the right track here.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.