<?php

namespace domain\_;

use yii\base\Model;
use yii\db\ActiveRecord;

abstract class AbstractBuilder extends AbstractService implements BuilderInterface
{
    public function create(Model $model): bool
    {
        return $model->save();
    }

    public function update(Model $model): bool
    {
        return $model->save();
    }

    public function delete(Model $model): bool
    {
        return $model->delete();
    }

    /**
     * @deprecated
     */
    public function saveCreate(ActiveRecord $model): bool
    {
        return $model->save();
    }

    /**
     * @deprecated
     */
    public function saveUpdate(ActiveRecord $model): bool
    {
        return $model->save();
    }

    /**
     * Status
     */

    public function updateStatusOnline(Model $model)
    {
        $model->status = StatusInterface::STATUS_ONLINE;
        $this->update($model);
    }

    public function updateStatusOffline(Model $model)
    {
        $model->status = StatusInterface::STATUS_OFFLINE;
        $this->update($model);
    }

    public function updateStatusDeleted(Model $model)
    {
        $model->status = StatusInterface::STATUS_DELETED;
        $this->update($model);
    }
}
