i am trying to run a public function whenever a js function is executed in laravel
here is my code:
select: function(info) {
  var title = prompt('Event Title:');
  calendar.addEvent({
          title: title,
          start: info.startStr,
          end: info.endStr,
          allDay: false
        });
            var start = info.startStr;
            var end = info.endStr;
            $title = title;
            $start = start;
            $end = end;
            $verified = 0;
            <?php echo \App\Http\Controllers\FullCalendarController::create();?>
        calendar.unselect();
},
the fuction runs whenever the user tries to add an event to the calendar
i want to specificaly run <?php echo \App\Http\Controllers\FullCalendarController::create();?> whenever the function is called but it always runs on load.
this is what the "create" function does:
public static function create()
{  
    DB::table('events')->insertGetId(
        ['title' => $title, 'start' => $start, 'end' => $end, 'verified']
    );
}
it does not work specificaly because the variables that the function uses ($title, $start, $end) are not defined until the function runs.
i have tried putting a laravel if statement around it but then it dosn't work at all and a js if statement runs it on load anyway.
 
    