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

When your controller interacts with your FooRepository and your FooRepository executes and returns:

$this->model->with('Bar')->get()

you're given Foo models with the related Bar models eager loaded. At this point, you're done with the FooRepository (it's job is done) and are working directly with those 2 models.

I'm not sure what capabilities methodInFooRepo() is supposed to provide, but it sounds like that method should probably be in Foo and not FooRepository. If your view or controller needs to continue to use FooRepository, your controller should already have a reference to that (using the IoC container or through some other way you've instantiated and made that available).

Last updated 7 months ago.
0

I'm not sure what capabilities methodInFooRepo() is supposed to provide, but it sounds like that method should probably be in Foo and not FooRepository.

Edited the original post with comments at the methods. Do you think this method must be in the Foo model? But i want a clean model file ( only with relations, id name, etc )

Last updated 7 months ago.
0

Sign in to participate in this thread!

LaraJobs

Your banner here too?

moonshades moonshades Joined 16 Mar 2014

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.