I want to limit my applicants list using pagination but i cant find a way to work it with auth(). is there a way for this to work?
Using the $users = User::paginate(5); works but i want to use the auth() for security reasons
already tried
'applicants' => auth()->user()->applicants->paginate(20)
'applicants' => auth()->user()->paginate(20)->applicants
User.php
// Model
public function applicants()
{
return $this->hasMany(Scholar::class,'owner_id');
}
ApplicantController.php
public function index()
{
// show all applicants
return view('applicants/index', [
'applicants' => auth()->user()->applicants //reutrn as collection if i dd()
]);
}
foo.blade.php
{{ $applicants->links() }}
{{ $applicants->onEachSide(5)->links() }}
routes/web.php
Route::resource('applicants', 'ApplicantController');