/** * Return organization ID by its name. If the organization does not exist, create it * * @param string $organizationName * @return int The ID of the organization */ private function insertOrFetch(string $organizationName) : int { $organization = $this->organization->getByName($organizationName); if ($organization !== null) { return $organization->id; } return DB::table('organizations')->insertGetId(['name' => $organizationName]); }
/** * {@inheritdoc} */ public function getRelatedByName(string $name) : array { $organization = $this->organization->getByName($name); if ($organization === null) { throw new ModelNotFoundException(); } return $this->getRelated($organization->id); }