<?php
namespace App\Models;

use App\Core\Model;

class Deposit extends Model
{
    public function create($data)
    {
        $pdo = self::getPDO();
        $pdo->beginTransaction();
        try {
            $depositId = $this->insert('deposits', $data);
            $clientModel = new Client();
            $clientModel->updateBalance($data['client_id'], $data['amount'], 'add');
            $pdo->commit();
            return $depositId;
        } catch (\Exception $e) {
            $pdo->rollBack();
            throw $e;
        }
    }
}