Retriving results based on foreign key

Hi

Struggling to understand how ORM working… can someone explain how I would write the following to retrieve the results based on the foreign key which is ‘partner_id’ rather than fetching all the records back in the database table, so the url would be /partners-waters/1 displaying only the waters that, that partner owns?

public function index()
    {
        $this->paginate = [
            'contain' => ['Partners', 'StandardWaterTypes'],
        ];
        $partnersWaters = $this->paginate($this->PartnersWaters);
        $this->set(compact('partnersWaters'));
    }

It’s ok I figured it out :blush:

 public function index($partner_id)
    {
        $this->paginate = [
            'contain' => ['Partners', 'StandardWaterTypes'],
        ];
        $partnersWaters = $this->paginate(
            $this->PartnersWaters->find()
                ->where([
                    'partner_id' => $partner_id,
                    'partnersWaters.status' => 1
                ]));

        $this->set(compact('partnersWaters'));
    }