2016-10-09 1 views
0

mysql 데이터베이스에서 일부 데이터를 출력하기 위해 jquery datatables를 사용하려고합니다. 여기 라우트 [payments-data]가 laravel 5.3에서 정의되지 않았습니다.

내 경로입니다 :

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

내 컨트롤러 여기

<?php 

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); 
    } 

HomeController 내 블레이드 /이다 : 나는를 실행하려고 할 때, 그러나

@extends('layouts.master') 
@section('content') 

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


        <thead> 
        <tr> 
         <th>Id</th> 
         <th>Name</th> 
         <th>Amount</th> 
        </tr> 
        </thead> 
       </table> 
      </div> 
      </div> 
      @push('scripts') 
      <script> 
       $(function() { 
        $('#payments-table').DataTable({ 
         processing: true, 
         serverSide: true, 
         scrollX: true, 
         ajax: '{!! route('payments-data') !!}', 
         columns: [ 
          { data: 'id', name: 'id' }, 
          { data: 'name', name: 'name' }, 
          { data: 'amount', name: 'amount' }, 
         ] 
        }); 
       }); 
      </script> 
      @endpush  
      @endsection 

route /datatables Route를 얻습니다. [payments-data] not defined. (View: /home/bob/Desktop/dibon/resources/views/payments.blade.php) 무엇이 잘못 될 수 있습니까? 누군가.

답변

0

Route::get('payments-data', ['as' => 'HomeControllerPaymentsData', 'uses' => '[email protected]']);에 정의 된대로 {!! route('HomeControllerPaymentsData') !!}을 사용하십시오.

+0

고마워. 일했다! – bmm

관련 문제