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

HHvis's avatar
Level 1

Dynamic way to assign person to the table

I need to assign student to the group, even if there are 10 groups, one student can only be assign to one group, so no duplication. Also, once student is selected, there must be group name assigned to his name in 'Students' list. All this happening in one view. Groups are generated through nested loop with variables from another view.

I've been struggling with this for couple of days and can't find an easy solution. Any help is appreciated!

0 likes
4 replies
HHvis's avatar
Level 1

@Elliot_putt Thank you. I have thought about it. public function group(){ return $this->belongsTo(Group::class); } I can do it like that, although I dont need to save all the data in DB, I would be happy to lock it in the page until it reloads for now.

1 like
Elliot_putt's avatar

@HHvis No Problem you could always save it in a cookie or session when the user logs in worse case!

Please or to participate in this conversation.