0

I would like to query multiple tables from multiple databases.

My first query should return an array of sites_id.

The second request should return manufacturers_id based on the sites_id returned in the first request.

How do I set this up?

My repository:

    public function getSitesImminence()
{
    $arraySites = PublicationSite::
    select('sites_id')
    ->where('publi_code', '=', 'imminence_intercab')
    ->where('publi_status', '>', '0')
    ->get();
    return $arraySites;
}

public function getManufacturersMls($arraySites){
    $arrayManufacturers = Site::
    select('manufacturers_list')
    ->where('sites_id', '=', $arraySites)
    ->get();
    return $arrayManufacturers;
    }

My controller:

        $toto = $siteRepository->getSitesImminence()->getManufacturersMls($arraySites);

My error:

Method getManufacturersMls does not exist.

1 Answer 1

1

This isn't tested but your code should look more like this:

$arraySites = $siteRepository->getSitesImminence();
$toto = $siteRepository->getManufacturersMls($arraySites);

and your function should be a little different, using whereIn:

public function getManufacturersMls($arraySites){
    $arrayManufacturers = Site::
    select('manufacturers_list')
        ->whereIn('sites_id', $arraySites)
        ->get();
    return $arrayManufacturers;
 }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.