Laravel Pagination Error -- Call to undefined method stdClass::links()

Jishad picture Jishad · Feb 17, 2015 · Viewed 9.6k times · Source

I developed a laravel application and i want to paginate a view,

look my controller.

$times=DB::table('timesheets')   
->leftJoin('users', 'timesheets.timesheet_user', '=', 'users.id')
->leftJoin('projects','projects.project_id','=','timesheets.timesheet_project_id')
->where('timesheet_user','=',$user)
->paginate(5);
return View::make('timesheet/index')->with('times',$times)->with('projects',$projects);

Getting result finly in view, but when i try to show the links. it showing error like below,

   Call to undefined method stdClass::links() 

 <?php echo $times->links(); ?> 

what is the error in my code ?

THanks

Answer

Jishad picture Jishad · Aug 21, 2015

Its Wrong in my template file.

        <tbody>
          @foreach($qualdatas as $qualdata)
           <tr>
             <td>{{$qualdata->qualification_name}}</td>                
           </tr>
          @endforeach 
        </tbody>
       </table>
     {{$qualdatas->links()}}

In My template file, The foreach alias name and array name are same. Thant is because getting error like this.

When I change the alias name to different, Its working as beautiful. !!!