File "ModelRepository.php"

Full Path: /var/www/html/back/.git/ModelRepository.php
File size: 1.38 KB
MIME-type: text/x-php
Charset: utf-8

<?php

namespace App\Repositories\Model;


use App\Models\Account;
use App\Models\Counterparty;
use App\Models\Organization;
use App\Models\System;
use App\Repositories\Model\Interfaces\ModelInterface;
use Illuminate\Support\Collection;

class ModelRepository implements ModelInterface
{
    public function getAccounts(int $modelId, $archive)
    {
        return Account::query()->where(['model_id' => $modelId, 'archived' => $archive])->with(['organization', 'payments'])->get();
    }

    public function getCashAccounts(int $modelId, bool $isCash, bool $archive = false)
    {
        return Account::query()->where(['model_id' => $modelId, 'is_cash' => $isCash, 'archived' => $archive])->with(['organization', 'payments'])->get();
    }

    public function getCounterparties($modelId, $archive)
    {
        return Counterparty::query()->where(['model_id' => $modelId, 'archived' => $archive])->get();
    }

    public function getOrganizations($modelId, $archive)
    {
        return Organization::query()->where(['model_id' => $modelId, 'archived' => $archive])->get();
    }

    public function getModel(int $modelId)
    {
        return System::query()->findOrFail($modelId);
    }

    public function getAll(): Collection
    {
        return System::query()->get();
    }

    public function update(int $modelId, array $data)
    {
        return System::find($modelId)->update($data);
    }
}