0

I have models called "events" and "customer". I want to create a relationship from frontend when a user press the "Event enrol" Button.

I've setup this process from backend. But I can't figure out how to do this from frontend(client side) in components.

Dapk
  • 203
  • 2
  • 10
  • you just need `event id` pass it to component's Ajax handler up on `enrol` button press, in ajax handler just find relative event then get current login user, get its id and `$eventModel->user_id = $loginUser->id;` and save it. this will do – Hardik Satasiya Mar 12 '19 at 06:34
  • 1
    @Hardik Satasiya worked well thank you very much! – Dapk Mar 12 '19 at 15:23
  • One more question! User have children. Those children are also enroll in the event. How to display children belongs to the logged in user and save to the enrollment table. ( I've manage to display children as check boxes using a component. But it displays all the students in the system. – Dapk Mar 12 '19 at 15:28
  • you can extend `user` with https://stackoverflow.com/questions/49959096/relationship-between-user-and-category-octobercms/49974644#49974644, here you define relation user <-> children SAME goes in children modal where you will have `user_id` which user its belongs to then you can use `$user->children` to get all related children. - for enrolment you need mm table where you have `child_id` and `event_id` – Hardik Satasiya Mar 14 '19 at 07:05

0 Answers0