<?php

namespace App\Scopes;

use App\Domains\Admin\Repositories\AdminTenantRepository;
use App\Domains\Admin\Repositories\AdminUserRepository;
use App\Models\Tenant;
use App\Providers\AuthCheckProvider;
use App\Repositories\CostUnitRepository;
use App\Repositories\EstimatesRepository;
use App\Repositories\EventParticipantRepository;
use App\Repositories\EventRepository;
use App\Repositories\InvoiceRepository;
use App\Repositories\PageTextRepository;
use App\Repositories\UserRepository;

abstract class CommonController {
    protected Tenant $tenant;
    protected UserRepository $users;
    protected CostUnitRepository $costUnits;

    protected PageTextRepository $pageTexts;

    protected InvoiceRepository $invoices;
    protected EventRepository $events;
    protected EventParticipantRepository $eventParticipants;
    protected EstimatesRepository $estimates;
    protected AdminUserRepository $adminUsers;
    protected AdminTenantRepository $adminTenants;

    public function __construct() {
        $this->tenant = app('tenant');
        $this->users = new UserRepository();
        $this->costUnits = new CostUnitRepository();
        $this->pageTexts = new PageTextRepository();
        $this->invoices = new InvoiceRepository();
        $this->events = new EventRepository();
        $this->eventParticipants = new EventParticipantRepository();
        $this->estimates = new EstimatesRepository();
        $this->adminUsers = new AdminUserRepository();
        $this->adminTenants = new AdminTenantRepository();
    }

    protected function checkAuth() {
        $authCheckProvider = new AuthCheckProvider;
        return $authCheckProvider->checkLoggedIn();
    }
}
