bmm bmm - 3 months ago 42
jQuery Question

Route [payments-data] not defined in laravel 5.3

I am trying to use jquery datatables to output some data from a mysql database.

Here is my route:

Route::get('datatables', ['as' => 'HomeController', 'uses' => 'HomeController@getIndex']);
Route::get('payments-data', ['as' => 'HomeControllerPaymentsData', 'uses' => 'HomeController@Payments']);

My controller


namespace App\Http\Controllers;

use Illuminate\Http\Request;
use DB;
use Carbon\Carbon;

class HomeController extends Controller

public function getIndex()
return view('payments');

* Process datatables ajax request.
* @return \Illuminate\Http\JsonResponse
public function Payments()
return Datatables::of(DB::table('Payment'))->make(true);

Here is my blade/view:


<div class="table-responsive">
<table class="table table-hover" id="payments-table">

$(function() {
processing: true,
serverSide: true,
scrollX: true,
ajax: '{!! route('payments-data') !!}',
columns: [
{ data: 'id', name: 'id' },
{ data: 'name', name: 'name' },
{ data: 'amount', name: 'amount' },

However, when I try to run the route
I get Route
[payments-data] not defined. (View: /home/bob/Desktop/dibon/resources/views/payments.blade.php)
What could be doing wrong? Anyone.


Use {!! route('HomeControllerPaymentsData') !!} as defined in Route::get('payments-data', ['as' => 'HomeControllerPaymentsData', 'uses' => 'HomeController@Payments']);.