Find a related model by its primary key.

@param  mixed  $id
@param  array  $columns
@return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection|null
492249
public function find($id, $columns = ['*'])
    {
        return is_array($id) ? $this->findMany($id, $columns) : $this->where(
            $this->getRelated()->getQualifiedKeyName(), '=', $id
        )->first($columns);
    }
213372
public function find($postId, $columns = ['*'])
    {
        $cache_key = (is_array($columns) && $columns[ 0 ] == '*') ? 'post_' . $postId : 'post_' . md5($postId . http_build_query($columns));

        // See if we've the post cached earlier in this request and return it if it's available
        if (Cache::tags(['posts', 'post_' . $postId])->has($cache_key)) {
            return Cache::tags(['posts', 'post_' . $postId])->get($cache_key);
        } else {
            // Eventually we try to fetch the post from the database or return an error
            try {
                $post = $this->postRepository->findOrFail($postId, $columns);
                // Cache it using the caching system
                Cache::tags(['posts', 'post_' . $postId])
                     ->put($cache_key, $post, \Option::get('posts_cache_expires', 60));

                return $post;
            } catch (\Exception $e) {
                return null;
            }
        }
    }
204240
public static function find($ids, $columns = ['*'])
    {
        $me = new self;
        $query = $me->newQuery();

        foreach ($me->getKeyName() as $key) {
            $query->where($key, '=', $ids[$key]);
        }

        return $query->first($columns);
    }
285030
public function findBy($field, $id, array $columns = ['*'])
    {
        $this->applyCriteria();

        $model = $this->model->where($field, $id)->first($columns);

        if ( ! $model )
            throw new RepositoryException("Model does not exist.");

        return $model;
    }
465680
public function findById($id)
    {
        if (count($this->primaryKeys) > 1) {
            throw new \LogicException(__METHOD__ . '|Cannot use findById() method for table with multiple primary keys !');
        }

        $field = reset($this->primaryKeys);

        return $this->findByKeys(array($field => $id));
    }
1086732
public function getChildren(array $columns = ['*'])
    {
        if ($this->hasChildrenRelation()) {
            $result = $this->getRelation($this->getChildrenRelationIndex());
        } else {
            $result = $this->children()->get($columns);
        }

        return $result;
    }
213370
public function find($id, $columns = array('*'))
	{
		if (is_array($id))
		{
		    return $this->findMany($id, $columns);
		}

		$this->query->where($this->model->getKeyName(), '=', $id);

		return $this->first($columns);
	}
1119835
public function find($id)
    {
        $this->newQuery();

        $this->queryBuilder->whereEqual($this->primaryFieldName, $id);

        $queryKey = $this->queryBuilder->firstQueryKey();

        if (!$this->isCompleteKey($queryKey)) {
            return null;
        }

        list($method, $parameters) = $this->getFindMethodAndParameters();

        array_unshift($parameters, $queryKey);
        $value = call_user_func_array([$this->redClient, $method], $parameters);

        return $value;
    }
1153805
def find(self, id, columns=None):
        
        if not columns:
            columns = ['*']

        return self.where('id', '=', id).first(1, columns)
1152002
public function findById($id) {
        $this->sqlBuilder->addWhere($this->primaryKey, $id);
        $sql = $this->sqlBuilder->buildQueryString();
        return $this->db->getOneRow($sql);
    }
614603
public function findOrFail($id, $columns = ['*'], $with = [])
    {
        $cacheKey = $this->generateKey([$id, $columns, $with]);

        return $this->cacheResults(get_called_class(), __FUNCTION__, $cacheKey, function () use ($id, $columns, $with) {
            return $this->model->with($with)
                ->findOrFail($id, $columns);
        });
    }
381168
public function findWith($find, array $with = [], $column = 'id', array $columns = ['*'])
    {
        return $this->whereWith($find, $column, $with)->firstOrFail($columns);
    }
606630
public function findByField($field, $value = null, $columns = ['*'])
    {
        return parent::findByField(
            $this->getColumnName($field),
            $value,
            $this->getColumnsNames($columns)
        );
    }
995988
static public function find($id)
    {
        $model = new static;
        $result = $model->execute('SELECT * FROM '.$model->table.' WHERE '.$model->key.' = ?', [$id]);
        if (is_array($result)) {
            $result = current($result);
        }
        return $result;
    }
303117
public function find($id = null)
    {
        // ID has to be defined
        if (!isset($id)) {
            throw new \InvalidArgumentException('Undefined ID to find', 400);
        }

        // Return the first found record using the primary key for the where
        $result = $this->where($this->primaryKey, $id, '=', $this->table)->limit(1)->first();

        // Return the first matching record
        return $result;
    }
777860
public function get(string $id)
    {
        return isset($this->columns[$id]) ? $this->columns[$id] : false;
    }
951063
public function findMany($id, $columns = ['*'])
    {
        if (empty($id)) {
            return new EntityCollection();
        }

        $this->query->whereIn($this->entityMap->getKeyName(), $id);

        return $this->get($columns);
    }