Hi,
I have the following situation:
I have the tables: actions action_access_ids
It's a one-to-many-relationship. One action can have many action_triggers.
Now I get the access_ids this way:
$action = Action::with('access_ids')->find(1);
Then, I can access all of the access_ids like this:
$action->access_ids[0]->value // first $action->access_ids[1]->value // second $action->access_ids[2]->value // third
But this way I don't know which access_id I'm selecting, because I only have an array with keys starting from 0. But every access_id has a name attribute to identify it.
Is something like this possible?:
$action->access_ids->get('nameOfAccess_id');
This method get() would loop through the access_ids and return the value of access_id with the name given. If this would be possible, where should I place this method in my Code?
Thank you in advance
d3mueller
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community