firefly-iii/app/Models/UserGroup.php

140 lines
4.0 KiB
PHP
Raw Normal View History

2021-08-28 08:47:33 -05:00
<?php
2021-09-16 07:21:35 -05:00
2021-08-28 08:47:33 -05:00
/*
* UserGroup.php
* Copyright (c) 2021 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2021-09-16 07:21:35 -05:00
declare(strict_types=1);
2021-08-28 08:47:33 -05:00
namespace FireflyIII\Models;
2021-09-18 03:20:19 -05:00
use Eloquent;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
2021-08-28 08:47:33 -05:00
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
2023-08-10 23:04:03 -05:00
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
2021-09-18 03:20:19 -05:00
use Illuminate\Support\Carbon;
2021-08-28 08:47:33 -05:00
/**
* Class UserGroup
2021-09-18 03:08:10 -05:00
*
2023-07-15 09:02:42 -05:00
* @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property string|null $deleted_at
* @property string $title
2021-09-18 03:21:29 -05:00
* @property-read Collection|GroupMembership[] $groupMemberships
2023-07-15 09:02:42 -05:00
* @property-read int|null $group_memberships_count
2021-09-18 03:20:19 -05:00
* @method static Builder|UserGroup newModelQuery()
* @method static Builder|UserGroup newQuery()
* @method static Builder|UserGroup query()
* @method static Builder|UserGroup whereCreatedAt($value)
* @method static Builder|UserGroup whereDeletedAt($value)
* @method static Builder|UserGroup whereId($value)
* @method static Builder|UserGroup whereTitle($value)
* @method static Builder|UserGroup whereUpdatedAt($value)
2023-07-15 09:02:42 -05:00
* @property-read Collection<int, Account> $accounts
* @property-read int|null $accounts_count
2023-09-01 12:40:17 -05:00
* @property-read Collection<int, \FireflyIII\Models\AvailableBudget> $availableBudgets
* @property-read int|null $available_budgets_count
* @property-read Collection<int, \FireflyIII\Models\Bill> $bills
* @property-read int|null $bills_count
* @property-read Collection<int, \FireflyIII\Models\Budget> $budgets
* @property-read int|null $budgets_count
* @property-read Collection<int, \FireflyIII\Models\PiggyBank> $piggyBanks
* @property-read int|null $piggy_banks_count
* @property-read Collection<int, \FireflyIII\Models\TransactionJournal> $transactionJournals
* @property-read int|null $transaction_journals_count
2021-09-18 03:20:19 -05:00
* @mixin Eloquent
2021-08-28 08:47:33 -05:00
*/
class UserGroup extends Model
{
protected $fillable = ['title'];
/**
2023-05-29 06:56:55 -05:00
* Link to accounts.
2021-08-28 08:47:33 -05:00
*
* @return HasMany
*/
2023-05-29 06:56:55 -05:00
public function accounts(): HasMany
2021-08-28 08:47:33 -05:00
{
2023-05-29 06:56:55 -05:00
return $this->hasMany(Account::class);
2021-08-28 08:47:33 -05:00
}
2023-08-06 00:04:09 -05:00
/**
* Link to bills.
*
* @return HasMany
*/
public function availableBudgets(): HasMany
{
return $this->hasMany(AvailableBudget::class);
}
/**
* Link to bills.
*
* @return HasMany
*/
public function bills(): HasMany
{
return $this->hasMany(Bill::class);
}
/**
* Link to budgets.
*
* @return HasMany
*/
public function budgets(): HasMany
{
return $this->hasMany(Budget::class);
}
/**
*
* @return HasMany
*/
2023-05-29 06:56:55 -05:00
public function groupMemberships(): HasMany
{
2023-05-29 06:56:55 -05:00
return $this->hasMany(GroupMembership::class);
}
2023-08-10 23:04:03 -05:00
/**
* Link to piggy banks.
*
* @return HasManyThrough
*/
public function piggyBanks(): HasManyThrough
{
return $this->hasManyThrough(PiggyBank::class, Account::class);
}
/**
* Link to transaction journals.
*
* @return HasMany
*/
public function transactionJournals(): HasMany
{
return $this->hasMany(TransactionJournal::class);
}
2021-09-16 07:21:35 -05:00
}