/** * Get a user by its ID. * * @param mixed $id * @return \Stidges\LaravelDbNormalizer\Entity */ public function getById($id) { $users = $this->files->getRequire($this->path); $result = []; foreach ($users as $user) { if ($user['id'] == $id) { $result = $user; break; } } return $this->normalizer->normalize($result); }
/** * Get a user by its ID. * * @param mixed $id * @return \Stidges\LaravelDbNormalizer\Entity */ public function getById($id) { $user = $this->db->table($this->table)->where('id', $id)->first(); return $this->normalizer->normalize($user); }
/** * Get a user by its ID. * * @param mixed $id * @return \Stidges\LaravelDbNormalizer\Entity */ public function getById($id) { $user = $this->model->find($id); return $this->normalizer->normalize($user->toArray()); }