bmm bmm - 1 year ago 148
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.

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download