sultanwebdev's avatar

join table cant Display pagination & View Page Data

Function here any one help me please

 public function SubCategory(){
    $subcategory = DB::table('subcategories')
    ->join('categories','subcategories.category_id','categories.id')
    ->select('subcategories.*','categories.category_en')
    ->orderBy('id','desc')
    ->paginate(5);
    return view('backend.subcategory.subcategory',compact('subcategory'));
}// end method  
view page :

<div class="col-lg-12 grid-margin stretch-card">
    <div class="card">
      <div class="card-body">

        <h4 class="card-title">SubCategory Page</h4>

        <div class="template-demo"> 
            <a href="{{ route('add.subcategory') }}"> <button type="button" class="btn btn-primary btn-fw" style="float: right;" >Add SubCategory</button> </a>



        </div>
       
        <div class="table-responsive">
          <table class="table table-bordered">
            <thead>
                @php($i = 1) 
              <tr>
                <th> # </th>
                <th> Subcategory English</th>
                <th> Subcategory Bangla</th>
                <th> Category Name</th>
                <th> Action </th>
              </tr>
            </thead>
            <tbody>

                @foreach ($subcategory as $item)     
    <tr>
        <td> {{ $i++ }} </td>
        <td>{{ $item->subcategory_en }} </td>
        <td>{{ $item->subcategory_bn }} </td>
        <td>{{ $item->category_en }} </td>
       
        <td> 
            
        <a href="{{ route('edit.subcategory',$item->id) }}" class="btn btn-info">Edit</a>
        <a href="{{ route('delete.subcategory',$item->id) }}" id="delete" class="btn btn-danger">Delete</a>
        </td>
    </tr>     
    @endforeach
             
              
            </tbody>
          </table>
          {{ $subcategory->links('pagination-links') }}
        </div>
      </div>
    </div>
  </div>
@endsection```
0 likes
5 replies
jlrdw's avatar

You need to work out a custom lengthaware paginator. What is 'pagination-links' in your code?

sultanwebdev's avatar

@jlrdw bro when i write code join then cant work my page view show blank page but data have in dabatbase

jlrdw's avatar

@sultanwebdev I Are you loading the correct view, test and see by displaying a hello world or something.

jlrdw's avatar

@sultanwebdev check documentation for the correct usage of @php.

Also dd your query results and make sure you are getting results.

Please or to participate in this conversation.