|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Fabrica\Http\Api; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Http\Request; |
|
6
|
|
|
use Illuminate\Support\Facades\Event; |
|
7
|
|
|
|
|
8
|
|
|
use Fabrica\Http\Requests; |
|
9
|
|
|
use Fabrica\Http\Api\Controller; |
|
10
|
|
|
|
|
11
|
|
|
use DB; |
|
12
|
|
|
use Fabrica\Project\Provider; |
|
13
|
|
|
use Fabrica\Acl\Eloquent\RolePermissions; |
|
14
|
|
|
|
|
15
|
|
|
class ConfigController extends Controller |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* Display a listing of the resource. |
|
19
|
|
|
* |
|
20
|
|
|
* @return \Illuminate\Http\Response |
|
21
|
|
|
*/ |
|
22
|
|
|
public function index($project_key) |
|
23
|
|
|
{ |
|
24
|
|
|
$new_types = []; |
|
25
|
|
|
$types = Provider::getTypeList($project_key); |
|
26
|
|
|
foreach ($types as $type) |
|
27
|
|
|
{ |
|
28
|
|
|
if (isset($type->disabled) && $type->disabled) { |
|
29
|
|
|
continue; |
|
30
|
|
|
} |
|
31
|
|
|
$type->screen = $type->screen; |
|
32
|
|
|
$type->workflow = $type->workflow; |
|
33
|
|
|
$new_types[] = $type; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
$priorities = Provider::getPriorityList($project_key); |
|
37
|
|
|
$roles = Provider::getRoleList($project_key); |
|
38
|
|
|
foreach($roles as $role) |
|
39
|
|
|
{ |
|
40
|
|
|
$role->permissions = $this->getPermissions($project_key, $role->id); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
return response()->json([ 'ecode' => 0, 'data' => [ 'types' => $new_types, 'roles' => $roles, 'priorities' => $priorities ] ]); |
|
|
|
|
|
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* get permissions by project_key and roleid. |
|
48
|
|
|
* |
|
49
|
|
|
* @param string $project_key |
|
50
|
|
|
* @param string $role_id |
|
51
|
|
|
* @return array |
|
52
|
|
|
*/ |
|
53
|
|
View Code Duplication |
public function getPermissions($project_key, $role_id) |
|
|
|
|
|
|
54
|
|
|
{ |
|
55
|
|
|
$rp = RolePermissions::where([ 'project_key' => $project_key, 'role_id' => $role_id ])->first(); |
|
56
|
|
|
if (!$rp && $project_key !== '$_sys_$') { |
|
57
|
|
|
$rp = RolePermissions::where([ 'project_key' => '$_sys_$', 'role_id' => $role_id ])->first(); |
|
58
|
|
|
} |
|
59
|
|
|
return $rp && isset($rp->permissions) ? $rp->permissions : []; |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: