Find a model by its primary key.

@param  mixed  $id
@param  array  $columns
@return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection|static[]|static|null
515159
public function find($id, $columns = ['*'])
    {
        if (is_array($id) || $id instanceof Arrayable) {
            return $this->findMany($id, $columns);
        }

        return $this->whereKey($id)->first($columns);
    }
1153805
def find(self, id, columns=None):
        
        if not columns:
            columns = ['*']

        return self.where('id', '=', id).first(1, columns)
28239
public function findOrNew($id, $columns = ['*'])
    {
        if (!is_null($model = $this->find($id, $columns))) {
            return $model;
        }

        return $this->model->newInstance()->setConnection(
            $this->query->getConnection()->getName()
        );
    }
1215644
public function findOrFail($id, $columns = ['*'])
    {
        try {
            $resource = parent::findOrFail($id, $columns);
        } catch (ModelNotFoundException $e) {
            throw new NotFoundHttpException('Resource \'' . class_basename($e->getModel()) . '\' with given UUID ' . $id . ' not found');
        }

        return $resource;
    }
1185922
public function findOrFail($id, $columns = ['*'])
    {
        $this->parse();

        return $this->getHandler()->findOrFail($id, $this->getColumns($columns));
    }
1297821
public function get($columns = ['*'])
    {
        return $this->select($columns)->map(function ($row) {
            return Finder::createStore($row);
        });
    }
1247123
public function findOrNew($id, $columns = ['*'])
    {
        if (! is_null($model = $this->find($id, $columns))) {
            return $model;
        }

        return $this->newModelInstance();
    }
951063
public function findMany($id, $columns = ['*'])
    {
        if (empty($id)) {
            return new EntityCollection();
        }

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

        return $this->get($columns);
    }
252852
public function find($id, $properties = array('*')) {
        // If the dev did not specify the $id as an int it would break
        // so we cast it anyways.

        if (is_array($id)) {
            return $this->findMany(array_map(function($id) {
                                return (int) $id;
                            }, $id), $properties);
        } else {

            $id = $id;
        }

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

        return $this->first($properties);
    }
333325
public function selectColByIdsPreserveIds(array $ids = array(), $columnName = 'id')
    {
        if (empty($ids)) {
            return array();
        }

        $_query = $this->getSelectQueryByIds($ids);
        $_columnIndexId = $this->_getColumnIndexInSelectQuery($this->getIdentityColumn());
        $_columnIndex = $this->_getColumnIndexInSelectQuery($columnName);

        if ($_columnIndex === false || $_columnIndexId === false) {
            throw new \InvalidArgumentException(get_called_class() . '::' . __FUNCTION__ . '() Invalid column name given as second parametter. "' . $columnName . '" given');
        }

        $_stmt1 = $this->db->getAdapter()->query($_query);
        $columnIndexId = $_stmt1->fetchAll(Zend_Db::FETCH_COLUMN, $_columnIndexId);

        $_stmt2 = $this->db->getAdapter()->query($_query);
        $columnIndex = $_stmt2->fetchAll(Zend_Db::FETCH_COLUMN, $_columnIndex);
        $res = array_combine($columnIndexId, $columnIndex);
        if ($res !== false) {
            return $res;
        } else {
            throw new \RuntimeException("Not same count between ID and selected COLUMN");
        }
    }
327780
public function findByUid($id, $columns = ['*'])
    {
        $this->applyCriteria();
        $this->applyScope();
        $model = $this->model->where('uid', '=', $id)->firstOrFail($columns);
        $this->resetModel();

        return $this->parserResult($model);
    }
324219
public static function find(int $id): ORM
    {
        if (! ($instance = self::instance()->getById($id))) {
            throw new DatabaseException('Could not find ' . __CLASS__ .
                ' where primary key is ' . $id);
        }
        return $instance;
    }
1114140
public static function findOrFail($ids, $columns = ['*'])
    {
        $result = self::find($ids, $columns);

        if (!is_null($result)) {
            return $result;
        }

        throw (new ModelNotFoundException)->setModel(
            __CLASS__, $ids
        );
    }
84292
public function get($id, array $columns = [])
	{
		if(!empty($columns))
		{
			$this->select($columns);
		}

		return $this->where($this->model->getPrimaryKey(), '=', $id)->first();
	}
983602
public static function find($id, $columns = array('*'))
	{
		if (is_array($id) && empty($id)) return new Collection;

		$instance = new static;

		return $instance->newQuery()->find($id, $columns);
	}
337827
public function getModelByPrimaryKey($id)
    {
        foreach($this->models as $model)
        {
            $primaryKey = $model->getKeyName();
            if($model->$primaryKey == $id)
                return $model;
        }
    }
243525
public function findBySid($sid, $columns = [])
    {
        try {
            return $this->findBySidOrFail($sid, $columns);
        } catch (ModelNotFoundException $e) {
            return false;
        }
    }