Support the ongoing development of Laravel.io →
Eloquent Architecture
Last updated 7 months ago.
0

You can use $this->model->all()

Last updated 7 months ago.
0

TorchSK said:

You can use $this->model->all()

Many thanks TorchSK,

I haven't access to this static method.

Last updated 7 months ago.
0

And I think that this part

public function __construct(ModelName $model){
    $this->model = $model;
}

belongs to the repository that extends BaseRepository

Last updated 7 months ago.
0

TorchSK said:

And I think that this part

public function __construct(ModelName $model){ $this->model = $model; }

belongs to the repository that extends BaseRepository

Many thanks TorchSK i will try it.

Last updated 7 months ago.
0
   abstract class BaseRepository {

          protected $model;

          public function __construct($model = null)
          {
                 $this->model = $model;
          }

          public function getAll()
          {
                 $this->model->all();
          }

          public function findById($id)
          {
                 $this->model->find($id);
          }
   }
Last updated 7 months ago.
0

Many thanks for all both!

Last updated 7 months ago.
0

Sign in to participate in this thread!

LoadForge

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2022 Laravel.io - All rights reserved.