<?php

namespace App\Libraries;

class CompanyService
{
    public static function id()
    {
        return session()->get('company_id');
    }

    public static function getOrFail()
    {
        $id = session()->get('company_id');

        if (!$id && !session()->get('is_super_admin')) {
            redirect()->to('/admin/login')->send();
            exit;
        }

        return $id ? (int) $id : null;
    }

    public static function isSuperAdmin()
    {
        return (bool) session()->get('is_super_admin');
    }
}