To pass the publicId variable from JavaScript to the Laravel route helper, you can use an AJAX request to send the publicId value to a PHP script that will return the route URL with the publicId parameter. Here's an example:
Create a PHP script that accepts the publicId parameter and returns the route URL with the parameter:
This code sends a GET request to the /get-route-url/{publicId} URL with the publicId value as a parameter. The PHP script returns a JSON response with the routeUrl value, which is used to redirect the user to the correct route with the publicId parameter.
@Snapey Yes this works, but its not pretty. If the route change, then there is a problem.
Anyway i have worked solution, but its not clean. Yes, with livewire its very easy, but its okay.
This works greate. You can see, i can use the route helper, for the "Create Route", but not for "Edit".
dateClick: function(info) {
//livewire.emit('dateOnFullCalendarIsClicked',info.dateStr);
var date = info.dateStr;
var route = @json(route('shiftevents.create'));
var requestParam = route.concat('?date=');
var fullUrl = requestParam.concat(date);
window.location.href = fullUrl;
},
eventClick: function(info) {
var publicId = info.event._def.publicId;
var route = @json(url('/').'/dashboard/calendar-module/shiftevents/');
var addIdToUrl = route.concat(publicId);
var fullUrl = addIdToUrl.concat('/edit');
window.location.href = fullUrl;
},