<?php

namespace App\Model;

use Nette;

class FundManager
{
	use Nette\SmartObject;

	private Nette\Database\Explorer $database;

	public function __construct(Nette\Database\Explorer $database)
	{
		$this->database = $database;
	}

	public function getById($id)
	{
		return $this->database->table('fond')->get($id);
	}

	public function getAllFunds()
	{
		return $this->database->table('fond');
	}

	public function getByPersonId($personId)
	{
		return $this->database->table('fond')->where('ID_osoby', $personId);
	}

	public function createRecord($data)
	{
		return $this->database->table('fond')->insert($data);
	}

	public function updateRecord($data)
	{
		$id = $data['ID'];
		return $this->database->table('fond')->where('id', $id)->update($data);
	}

	public function removeRecord($id)
	{
		return $this->database->table('fond')->where('id', $id)->delete();
	}
}