You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feat: Use mapped attributes as property object #26
Additional context
I'm trying to use strict entities in the project and restrict calling mapped attributes: $u->name is not allowed, $u->username is allowed if $datamap['name'] = 'username' .
The library currently uses the old version of $u->{$attribute}.
I understand it doesn't make sense for a framework. Can you think of something for my case? Given the requirement not to call mapped attributes as object properties. $u->mapProperty(...) is a method, but it is protected.
I additionally installed your new "relations" package. It has the same behavior. It seems you are adding dynamic properties in the process, I have forbidden it.
// custom entity check/** * Is the attribute available for work? */privatefunctionhasAttribute(string$attribute): bool
{
returnarray_key_exists($attribute, $this->attributes);
}
// PostModel - table `post` (other TagModel - table `tag`)publicfunctiontags(): Relation
{
return$this->belongsToMany(TagModel::class, 'post_tag', 'post_id', 'tag_id', 'id', 'id');
}
EntityException: Attribute "__pivot_parent_id" of "Tag" not exist.
I have no intentions of changing the default framework behavior.
If you encounter issues with the new "relations" package, please report them in its repository and include the full context (migrations, relations definitions) so the problem can be reproduced easily.
I understand it doesn't make sense for a framework.
I found code. It sets the dynamic properties of objects (if the result is not an array). To check, I added these attributes, it seems to work. But that doesn't suit me - extra properties in the object.
To better understand my problem, imagine that all properties (not attributes) are these are the real private properties of the object and you cannot set new ones.
@michalsn it doesn't matter where the issue is open, do we have to write in both repositories? If you don't have an answer or time, then let's close it. I'll have to write my own solution.
What would really help here is a minimal reproducible example (migrations, models, entities, and a usage example) that I can copy and run locally. That would save me a lot of time trying to understand the exact scenario you're describing.
The last time I worked on this library was in early January, and without a runnable example, it's very difficult for me to follow the problem from snippets or links alone.
Also, it does matter where the issue is opened. The nested-model and the relations package are separate projects and are implemented differently, so mixing the discussion across repositories makes it harder to investigate.
At the moment, the only thing I clearly understand from your post is this:
I'm trying to use strict entities in the project and restrict calling mapped attributes:
$u->name is not allowed, $u->username is allowed if $datamap['name'] = 'username' .
As I mentioned earlier, I have no intention of changing this behavior, as this is how the framework currently handles it. However, if you would like to introduce a config option for this behavior, feel free to open a PR, and I can review it.
Considering how I implemented it by extending the basic Entity, I'm not sure if you'll approve of my idea. When I came across this feature (temporary properties from tables) this will have a big BC on other projects where it is allowed (the default class of the framework).
I can open the blog development repository. He's just in the process 😄 I will try to create a branch for the test. But I think you can also add the desired test locally.
At this stage, this discussion will be about StrictEntity (for our conversation), and it applies to both of your repositories if we continue the discussion.
Activity
neznaika0 commentedon Mar 9, 2026
I additionally installed your new "relations" package. It has the same behavior. It seems you are adding dynamic properties in the process, I have forbidden it.
michalsn commentedon Mar 9, 2026
I have no intentions of changing the default framework behavior.
If you encounter issues with the new "relations" package, please report them in its repository and include the full context (migrations, relations definitions) so the problem can be reproduced easily.
neznaika0 commentedon Mar 9, 2026
Yes, I mentioned that.
I found code. It sets the dynamic properties of objects (if the result is not an array). To check, I added these attributes, it seems to work. But that doesn't suit me - extra properties in the object.
https://github.com/michalsn/codeigniter-relations/blob/df2a28b9174a2ee18611d97d980c7d9c74b839dd/src/Relations/BelongsToMany.php#L268-L277
To better understand my problem, imagine that all properties (not attributes) are these are the real private properties of the object and you cannot set new ones.
neznaika0 commentedon Mar 9, 2026
@michalsn it doesn't matter where the issue is open, do we have to write in both repositories? If you don't have an answer or time, then let's close it. I'll have to write my own solution.
michalsn commentedon Mar 9, 2026
What would really help here is a minimal reproducible example (migrations, models, entities, and a usage example) that I can copy and run locally. That would save me a lot of time trying to understand the exact scenario you're describing.
The last time I worked on this library was in early January, and without a runnable example, it's very difficult for me to follow the problem from snippets or links alone.
Also, it does matter where the issue is opened. The
nested-modeland therelationspackage are separate projects and are implemented differently, so mixing the discussion across repositories makes it harder to investigate.At the moment, the only thing I clearly understand from your post is this:
As I mentioned earlier, I have no intention of changing this behavior, as this is how the framework currently handles it. However, if you would like to introduce a config option for this behavior, feel free to open a PR, and I can review it.
neznaika0 commentedon Mar 9, 2026
Considering how I implemented it by extending the basic Entity, I'm not sure if you'll approve of my idea. When I came across this feature (temporary properties from tables) this will have a big BC on other projects where it is allowed (the default class of the framework).
I can open the blog development repository. He's just in the process 😄 I will try to create a branch for the test. But I think you can also add the desired test locally.
At this stage, this discussion will be about StrictEntity (for our conversation), and it applies to both of your repositories if we continue the discussion.
neznaika0 commentedon Mar 9, 2026
@michalsn see https://github.com/neznaika0/codeigniter-blog/tree/feat/relations
Rename the configs inside ./utils/ to run scripts. Delete it .dist in the names, create an .env,, run the tests.
for some of them to run successfully, uncomment the necessary attributes in the
Post,Tag.michalsn commentedon Mar 10, 2026
You can check PR #27