public firstOrFail ( array $columns = ['*'] ) : |
||
$columns | array | |
return |
public function firstOrFail($columns = ['*'])
{
if (!is_null($model = $this->first($columns))) {
return $model;
}
throw (new ModelNotFoundException())->setModel(get_class($this->model));
}
/** * Get the first specified model record from the database * * @return \Illuminate\Database\Eloquent\Model */ public function first() { $this->newQuery()->eagerLoad()->setClauses()->setScopes(); $model = $this->query->firstOrFail(); $this->unsetClauses(); return $model; }