2017-07-11 5 views
0

Ich mache CRUD und möchte Daten mit Paginierung.So bisher habe ich Daten von MySQL abgerufen, aber wenn ich auf die nächste Schaltfläche geklickt die Route nicht funktioniert.Vielen Dank im Voraus für die Hilfe. im Folgenden werde ich meinen Code bin Hochladen:Laravel Paginierung render() -Methode funktioniert nicht richtig

Hier ist mein Controller Index-Methode

public function index() 
{ 
    $alldat=DB::select("SELECT a.id as id,a.`name`as name,b.name as catName,(case when a.status=1 then 'Available' else 'out of stock' end) as status FROM `subcategories` a,`categories` b where a.cat_id=b.id"); 

    $query="SELECT a.id as id,a.`name`as name,b.name as catName,(case when a.status=1 then 'Available' else 'out of stock' end) as status FROM `subcategories` a,`categories` b where a.cat_id=b.id"; 

    $alldata = new Paginator($alldat, 5, 1); 

    return view('admin_theme.dynamic_files.subcategory.allSubCategory',compact('alldata')); 
} 

Hier ist meine Ansicht Blade-Datei:

<div class="form-body"> 
        <table class="table"> 
         <thead> 
         <tr> 
          <th>Id</th> 
          <th>SubCategory Name</th> 
          <th>ParrentCategory Name</th> 
          <th>Status</th> 
          <th>Action</th> 
         </tr> 
         </thead> 
         <tbody> 
         @foreach($alldata as $data) 
          <tr class="success"> 
           <td>{{$data->id}}</td> 
           <td>{{$data->name}}</td> 
           <td>{{$data->catName}}</td> 
           <td>{{$data->status}}</td> 
           <td><a href="{{route('subcategory.edit',$data->id)}}" class="btn btn-info" role="button">Edit</a> 
            <a href="" class="btn btn-danger" role="button">Delete</a> 
           </td> 
          </tr> 
         @endforeach 
         </tbody> 
        </table> 
        {!!$alldata-> render()!!} 
       </div> 

Bitte, Hilfe anyone.Thanks in ad Vance

+0

, was Sie bekommen, wenn dd ($ alldata) ..? –

+0

nach give dd: Paginator {# 207 ▼ #hasMore: true #items: Sammlung {# 221 ▼ #items: array: 5 [▼ 0 => {# 208} ▶ 1 => {# 210 ▶ } 2 => {# 211} ▶ 3 => {# 212} ▶ 4 => {# 213} ▶ ] } #perPage: 5 #currentPage: 1 #PATH: "/" #query: [] #fragment: null #pageName: "page" } –

+0

hier ist der Pfad "/", ich denke es sollte resolve.any Idee sein? –

Antwort

0

Versuchen Sie diesen Code

public function index() 
{ 
    $alldata = DB::select(DB::raw("SELECT a.id as id,a.`name`as name,b.name as catName,(case when a.status=1 then 'Available' else 'out of stock' end) as status FROM `subcategories` a,`categories` b where a.cat_id=b.id")); 

    $alldata = $alldata->paginate(5); 

    // return code.. 
} 
+0

ich versucht, aber geben: (1/1) FatalThrowableError Aufruf einer Member-Funktion Paginieren() auf Array –

+0

ich Update haben ans versuchen jetzt –

+0

no..same Fehler ... (1/1) FatalThrowableError Aufruf an eine Member-Funktion paginate() auf Array –

Verwandte Themen