Capture domain in Laravel routes file as url variable

I have a problem capturing the domain in the routes file. When a route is written like this: Route::domain(‘mydomain.com’) ->get(‘/’, function () { return "It works"; }); And I access mydomain.com, I correctly get status 200 and a string It works. But when the routes are changed to this: Route::domain(‘{domain}’) ->get(‘/’, function () { return… Read More Capture domain in Laravel routes file as url variable

How to set custom route name before main route in Laravel?

I want to add username before each route.. ex: sam/productDashboard james/productDashboard note – Username is getting from session. i tried like this. it doesn’t work Route::get( session()->get(‘name’).’/productDashboard’,[ProductController::class,’ProductDashboard’])->name(‘productDashboard’); >Solution : This is not the way to use variable inside a route. Do it like this: Route::get(‘{username}/productDashboard’,[ProductController::class,’ProductDashboard’])->name(‘productDashboard’); and when you are referencing to this route with a… Read More How to set custom route name before main route in Laravel?

how can i set url of route from AJAX

WEB (route) : Route::get(‘/ajax-cat/edit/{id}’, [App\Http\Controllers\AjaxCRUDController::class, ‘categoryEdit’])->name(‘ajax.categoryEdit’); AJAX Code: $(document).ready(function () { $("#categoryBtn").click(function () { $("#catTable").show(); let html = ”; let i = 0; $.ajax({ url: ‘/ajax-cat’, type: "GET", success: function (data) { for (const x of data) { html += `<tr> <th scope="row">${++i}</th> <td>${x.name}</td> <td><a href="{{route(‘ajax.categoryEdit’,${x.id})}}" class="btn btn-danger">Edit</a></td> </tr>`; } $("#catTableBody").html(html); } }); }); });… Read More how can i set url of route from AJAX