public firstOrFail ( mixed $query = [], array $projection = [], boolean $cacheable = false ) : mixed | ||
$query | mixed | MongoDB query to retrieve the document. |
$projection | array | Fields to project in Mongo query. |
$cacheable | boolean | Retrieves the first through a CacheableCursor. |
Résultat | mixed | First document matching query as an $this->schema->entityClass object |
public function firstOrFail($query = [], array $projection = [], bool $cacheable = false)
{
if ($result = $this->first($query, $projection, $cacheable)) {
return $result;
}
throw (new ModelNotFoundException())->setModel($this->schema->entityClass);
}