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

How to load method CustomRepositoryEloquent of other CustomRepositoryEloquent? #224

Open
ssheduardo opened this issue Jun 16, 2016 · 5 comments

Comments

@ssheduardo
Copy link

Hi,
I have one doubth, how to load one method (...RepositoryEloquent) of other CustomerRepositoryEloquent

Example:

<?php
namespace App\Repositories;

use Prettus\Repository\Eloquent\BaseRepository;
use Prettus\Repository\Criteria\RequestCriteria;
use App\Entities\Tax;
use App\Validators\TaxValidator;

class TaxRepositoryEloquent extends BaseRepository implements TaxRepository
{
    public function model()
    {
        return Tax::class;
    }

    public function getTaxOfAmount($amount)
    {
        $tax = $this->find(config('company.tax'));
        $get_irpf = $tax->value*($amount/100);
        return $get_irpf;
    }

    public function boot()
    {
        $this->pushCriteria(app(RequestCriteria::class));
    }
}

Now, how to load the method getTaxOfAmount in my other CustomRepositoryEloquent ?

<?php
namespace App\Repositories;

use Prettus\Repository\Eloquent\BaseRepository;
use Prettus\Repository\Criteria\RequestCriteria;
use App\Entities\Custom;
use App\Validators\TaxValidator;

class CustomRepositoryEloquent extends BaseRepository implements CustomRepository
{
    public function model()
    {
        return Custom::class;
    }

    public function getCustom()
    {
        //How to load getTaxOfAmount?

    }

    public function boot()
    {
        $this->pushCriteria(app(RequestCriteria::class));
    }
}

Thanks.

@ssheduardo
Copy link
Author

Any idea?
Or the method getTaxOfAmount,move model to Tax.php?

@rushairer
Copy link

mark

@ssheduardo
Copy link
Author

????

@Sloaix
Copy link

Sloaix commented Nov 1, 2016

image

the ModelRepositoryEloquent was bound in app container.
if you want to use UserRepositoryEloquent in AdvertRepositoryEloquent.

$userRepository = app(UserRepositoryEloquent::class);

@aklevko
Copy link

aklevko commented May 15, 2017

Maybe is there another way?

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

4 participants