<?php

namespace App\Http\Controllers;

use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;

class PermissionController extends Controller {
  public function getPermissionsFromModule() { // /api/rpc/permission/getpermissionsfrommodule
    return DB::table('usr_perm_module')
      ->select('*')
      ->get();
  }

  public function getPermissionFromModule($id) { // /api/rpc/permission/getpermissionsfrommodule/id
    return DB::table('usr_perm_module')
      ->select('*')
      ->where('id', $id)
      ->get();
  }

  public function getPermissions($mdl) { // /api/rpc/permission/getpermissions/mdl
    return DB::table($mdl.'_permissions')
      ->select('*')
      ->get();
  }

  public function getPermissionGroup($mdl, $id) { // /api/rpc/permission/getpermissiongroup/mdl/id
    return DB::table($mdl.'_permissions')
      ->select('*')
      ->where('id', $id)
      ->get();
  }

  public function getPermissionUser($mdl, $id) { // /api/rpc/permission/getpermissionuser/mdl/id
    return DB::table($mdl.'_user_permissions')
      ->select('*')
      ->where('user_id', $id)
      ->get();
  }
}
