Domain\Config\ConfigRepository::update PHP Метод

update() публичный Метод

Update item of model.
public update ( array $data, integer $id ) : Domains\BaseModel
$data array
$id integer
Результат Domains\BaseModel
    public function update(array $data, $id)
    {
        if (empty($data)) {
            throw new RepositoryException('Empty data');
        }
        $model = $this->model->where('field', $id)->first();
        if (!$model) {
            throw new RepositoryException('Item not found');
        }
        try {
            $model->fill($data);
        } catch (Exception $e) {
            Log::error($e->getMessage());
            throw new RepositoryException('Empty fillable');
        }
        try {
            $model->save();
            return $model;
        } catch (Exception $e) {
            Log::error($e->getMessage());
            throw new RepositoryException('Error update');
        }
    }