/** * Find a model by its primary key. * * @param mixed $id * @param array $columns * @return mixed|static|null */ public function find($id, $columns = array('*')) { if (is_array($id)) { return $this->findMany($id, $columns); } $query = $this->query->where($this->model->getKeyName(), '=', $id); return $query->first($columns); }
/** * Add a "WHERE" clause to the given query. * * @param \Nova\Database\Query\Builder $query * @param string $key * @param string $extraValue * @return void */ protected function addWhere(QueryBuilder $query, $key, $extraValue) { if ($extraValue === 'NULL') { $query->whereNull($key); } elseif ($extraValue === 'NOT_NULL') { $query->whereNotNull($key); } else { $query->where($key, $extraValue); } }