Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Called a member function with() on null #1

Open
elhakimdev opened this issue Mar 11, 2021 · 6 comments
Open

Called a member function with() on null #1

elhakimdev opened this issue Mar 11, 2021 · 6 comments

Comments

@elhakimdev
Copy link

Hi. I have try to implement your repository pattern in my project. it was succesfully run. But in latest project. I have an error as i write in this issue tittle

( member function with() on null)

It is Anything possible to fix?

@elhakimdev
Copy link
Author

Im try to apply paginated data when call method all() in this repository

@carlomigueldy
Copy link
Owner

carlomigueldy commented Mar 13, 2021

Hi @elhakimdev , can you show me your code on where you experienced this error?

@carlomigueldy
Copy link
Owner

I recommend you create another method from the interface that will implement pagination. For example,

from EloquentRepositoryInterface.php

interface EloquentRepositoryInterafce
{
   // ... other methods

   public function withPagination(int $pages): Collection;
}

BaseRepository.php

class BaseRepository implements EloquentRepositoryInterface
{
   // ... other methods

  public function withPagination(int $pages): Collection
  {
     return $this->model->paginate($pages)->all();
  }
}

I hope this helps you. Sorry for the late response.

@elhakimdev
Copy link
Author

Okey.thanks for your repplies. I wass youre comment now. Let me try and check again about your recommendation.

Sorry for late response. But great thanks for your explanations. Better thanks regard elhakim dev

@carlomigueldy
Copy link
Owner

Happy to help!

@elhakimdev
Copy link
Author

elhakimdev commented Jun 26, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants