Find a model by its primary key or throw an exception.

@param string $id
@param  array $columns

@return \Illuminate\Database\Eloquent\Model

@throws \Illuminate\Database\Eloquent\ModelNotFoundException
424656
public function findOrFail($id, $columns = ['*'])
    {
        $this->newQuery();

        if ($result = $this->query->find($id, $columns)) {
            return $result;
        }

        throw (new ModelNotFoundException)->setModel($this->model);
    }
894446
public function getModel($id = 0, array $fields, array $columns)
    {
        //if we're getting an existing model, we'll want to first get the edit fields without the relationships loaded
        $originalModel = $model = $this->getDataModel();

        //get the model by id
        $model = $model->find($id);
        $model = $model ? $model : $originalModel;

        //if the model exists, load up the existing related items
        if ($model->exists) {
            $this->setExtraModelValues($fields, $model);
        }

        return $model;
    }
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);
	}
587987
public function firstOrFail($columns = ['*'])
    {
        $result = $this->query()->first($columns);

        if ( ! empty($result)) return $result;

        throw (new ModelNotFoundException)->setModel($this->model());
    }
763574
public function findMany($id, $columns = array('*'))
	{
		$this->query->whereIn($this->model->getKeyName(), $id);

		return $this->get($columns);
    }
346304
public static function find($id, array $columns = [])
    {
        $model = static::getInstance();
        $key   = static::getModelKey($id, $model);
        $query = [
            'ConsistentRead' => true,
            'TableName'      => $model->getTable(),
            'Key'            => $key,
        ];
        if ( ! empty( $columns )) {
            $query['AttributesToGet'] = $columns;
        }
        $item = $model->client->getItem($query);
        $item = array_get($item->toArray(), 'Item');
        if (empty( $item )) {
            return null;
        }
        $item = $model->unmarshalItem($item);
        $model->fill($item);
        // Set the model id field.
        $model->setId($id);
        $model->exists = true;
        $model->syncOriginal();

        return $model;
    }
1247123
public function findOrNew($id, $columns = ['*'])
    {
        if (! is_null($model = $this->find($id, $columns))) {
            return $model;
        }

        return $this->newModelInstance();
    }
670096
public function findMany($ids, $columns = ['*'])
    {
        return empty($ids) ? [] : $this->whereIn(
            $this->getRelated()->getQualifiedKeyName(), $ids
        )->get($columns);
    }
1294984
public function findOrFail($id)
    {
        if ($model = $this->find($id)) {
            return $model;
        }
        throw (new ModelNotFoundException)->setModel(get_class($this->getModel()));
    }
1003972
public function findModel($id)
    {
        if($this->_model === null) 
        {
            if($this->_model = $id ? Author::findOne($id) : null) 
            {
                return $this->_model;
            } else {
                throw new NotFoundHttpException(Module::t('core', 'The requested model does not exist.'));
            }
        }
    }
526241
protected function findModel($id)
    {
        /* @var $modelClass ActiveRecord */
        $modelClass = $this->modelClass;
        $keys = $modelClass::primaryKey();
        if (count($keys) > 1) {
            $values = explode(',', $id);
            if (count($keys) === count($values)) {
                $model = $modelClass::findOne(array_combine($keys, $values));
            }
        } elseif ($id !== null) {
            $model = $modelClass::findOne($id);
        }

        if (isset($model)) {
            return $model;
        } else {
            throw new NotFoundHttpException("Object not found: '$id'");
        }
    }
704704
public function run($id)
    {
        /** @var ActiveRecord $model */
        $model = new $this->modelClass;

        /*
         * Locate the supplied model, left, right and parent models
         */
        $pkAttribute = $model->getTableSchema()->primaryKey[0];

        /** @var ActiveRecord|NestedSetsBehavior $model */
        $model = $model::find()->where([$pkAttribute => $id])->one();

        if ($model == null) {
            throw new NotFoundHttpException('Node not found');
        }

        $name = Yii::$app->request->post('name');
        $model->{$this->nameAttribute} = $name;
        if (!$model->validate()) {
            throw new HttpException($model->getFirstError($this->nameAttribute));
        }
        $model->update(true, [$this->nameAttribute]);

        return null;
    }
281797
public function getBy($column, $value, array $columns = ['*'])
    {
        $result = $this->getBuilder()
                       ->select($columns)
                       ->where($column, '=', $value)
                       ->first();

        // Reset query builder
        $this->resetBuilder();

        return $result;
    }
327780
public function findByUid($id, $columns = ['*'])
    {
        $this->applyCriteria();
        $this->applyScope();
        $model = $this->model->where('uid', '=', $id)->firstOrFail($columns);
        $this->resetModel();

        return $this->parserResult($model);
    }
1043769
protected function findModel($id)
    {
        if (($model = Rubric::findOne($id)) !== null) {
            return $model;
        } else {
            throw new NotFoundHttpException(Module::t('core', 'The requested model does not exist.'));
        }
    }
84292
public function get($id, array $columns = [])
	{
		if(!empty($columns))
		{
			$this->select($columns);
		}

		return $this->where($this->model->getPrimaryKey(), '=', $id)->first();
	}
856879
public function find($id, $columns = ['*'])
    {
        $this->applyCriteria();
        $this->applyScope();
        $model = $this->model->findOrFail($id, $columns);
        $this->resetModel();

        return $this->parserResult($model);
    }