<?php
namespace App\Permissions;

use App\Permissions\Modules\Subscription;
use App\Permissions\Modules\Dashboard;
use App\Permissions\Modules\Products;
use App\Permissions\Modules\Providers;
use App\Permissions\Modules\Patients;
use App\Permissions\Modules\Orders;
use App\Permissions\Modules\Admin;
use App\Permissions\Modules\Role;
use App\Permissions\Modules\Analytics;
use App\Permissions\Modules\Prescription;
use App\Permissions\Modules\AdminPermissions;
use App\Permissions\Modules\Appointment;
use App\Permissions\Modules\LabKit;
use App\Permissions\Modules\Notes;
use App\Permissions\Modules\SiteSettings;

class Permissions
{
    private $modules=[
        Dashboard::class,
        Products::class,
        Providers::class,
        Patients::class,
        Orders::class,
        Admin::class,
        Role::class,
        Analytics::class,
        Subscription::class,
        Prescription::class,
        AdminPermissions::class,
        Notes::class,
        LabKit::class,
        SiteSettings::class,
        Appointment::class
    ];
    public $role_permissions;
    public function __construct($role_permissions)
    {
        $this->role_permissions = $role_permissions;
    }
    public function getPermissions()
    {
        $permissions = [];
        foreach($this->modules as $module_class)
        {
            $module = new $module_class($this->role_permissions);
            $permissions[] = $module->permissions();
        }
        return [
            "text"=>"Permissions",
            "a_attr"=> [
                "class"=>"no_checkbox"
            ],
            "state"=>["opened"=>true],
            "children"=>$permissions
        ];
    }
    public function permissionsApi()
    {
        $permissions = [];
        foreach($this->modules as $module_class)
        {
            $module = new $module_class($this->role_permissions);
            $permissions[] = $module->frontEndPermissions();
        }
        return $permissions;
    }
}
