<?php declare(strict_types=1);

namespace App\Domains\{{ domain }}\Model\Builder;

use App\Domains\Team\Model\TeamUser as TeamUserModel;
use App\Domains\Shared\Model\Builder\BuilderAbstract;

class {{ domain }} extends BuilderAbstract
{
    /**
     * @param string $email
     *
     * @return self
     */
    public function byEmail(string $email): self
    {
        return $this->where('email', strtolower($email));
    }

    /**
     * @param int $team_id
     *
     * @return self
     */
    public function byTeamId(int $team_id): self
    {
        return $this->whereIn('id', TeamUserModel::select('user_id')->where('team_id', $team_id));
    }

    /**
     * @param bool $enabled
     *
     * @return self
     */
    public function whereEnabled(bool $enabled): self
    {
        return $this->where('enabled', $enabled);
    }
}
