Oct 11, 2022
0
Level 4
How to link record between tables eventClick or pivot table
I have build a fullcaledar where i add some event in events. Also this evend saved in another table named jobs.
On events i save only job title and start_date &end_date on jobs i save more information like desc .... What i am looking for is how to create an eventClick on fullcalendar witch can show me the responsibile record on jobs. I use laravel for backend. But i dont know how to create pivot table for this two tables.
//event data mysql
+----+-------------+---------------------+---------------------+---------------------+---------------------+
| id | title | start_date | end_date | created_at | updated_at |
+----+-------------+---------------------+---------------------+---------------------+---------------------+
| 1 | Quemby Gill | 2022-10-13 02:02:00 | 2022-10-11 18:49:00 | 2022-10-11 13:38:43 | 2022-10-11 13:38:43 |
+----+-------------+---------------------+---------------------+---------------------+---------------------+
//job data mysql
+----+-------------+----------------------+----------------------+----------------+---------------------+----------------------+---------------+---------------------+---------------------+
| id | job_name | job_description | duration | client_name | client_phone_number | client_adress | job_completed | created_at | updated_at |
+----+-------------+----------------------+----------------------+----------------+---------------------+----------------------+---------------+---------------------+---------------------+
| 1 | Katelyn Roy | Nisi sed consectetur | Praesentium perferen | Giselle Wooten | +1 (225) 207-2411 | Ut voluptatibus quib | 0 | 2022-10-11 13:37:45 | 2022-10-11 13:37:45 |
| 2 | Quemby Gill | Consequuntur volupta | Tenetur adipisicing | Sharon Mosley | +1 (626) 727-7194 | Consequatur Tempor | 0 | 2022-10-11 13:38:43 | 2022-10-11 13:38:43 |
+----+-------------+----------------------+----------------------+----------------+---------------------+----------------------+---------------+---------------------+---------------------+
I use this method to save start and end date on calendar
$job = Job::create($request->all());
// this dont work couse i pass the `start_date` value, i cant pass id
// $job->schedules()->sync($request->input('start_date'));
if ($request->input('start_date') && $request->input('end_date')) {
EventCalendar::create([
'title' => $request->job_name,
'start_date' => $request->start_date,
'end_date' => $request->end_date,
]);
}
Please or to participate in this conversation.