<?php
namespace App\Core;

class TenantScope
{
    public static function condition(string $column = 'org_id'): string
    {
        if (!isset($_SESSION['role'])) {
            return '';
        }

        if ($_SESSION['role'] === 'super_admin') {
            return '';
        }

        if (isset($_SESSION['org_id'])) {
            return " WHERE $column = " . intval($_SESSION['org_id']);
        }

        return '';
    }
}
