Skip to content

Called a member function with() on null #1

Open
@elhakimdev

Description

@elhakimdev

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?

Activity

elhakimdev

elhakimdev commented on Mar 11, 2021

@elhakimdev
Author

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

carlomigueldy

carlomigueldy commented on Mar 13, 2021

@carlomigueldy
Owner

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

carlomigueldy

carlomigueldy commented on Mar 13, 2021

@carlomigueldy
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

elhakimdev commented on May 23, 2021

@elhakimdev
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

carlomigueldy commented on Jun 26, 2021

@carlomigueldy
Owner

Happy to help!

elhakimdev

elhakimdev commented on Jun 26, 2021

@elhakimdev
Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @carlomigueldy@elhakimdev

        Issue actions

          Called a member function with() on null · Issue #1 · carlomigueldy/laravel-repository-pattern