Commit f8026b32 authored by Viral Solani's avatar Viral Solani

Add created_at and updated_at in role and permission API

parent 7bd1501d
......@@ -16,10 +16,13 @@ class PermissionResource extends Resource
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'display_name' => $this->display_name,
'sort' => $this->sort,
'id' => $this->id,
'name' => $this->name,
'display_name' => $this->display_name,
'sort' => $this->sort,
'registered_at' => $this->created_at->toIso8601String(),
'last_updated_at' => $this->updated_at->toIso8601String(),
];
}
}
......@@ -16,12 +16,14 @@ class RoleResource extends Resource
public function toArray($request)
{
return [
'id' => $this->id,
'name' => $this->name,
'permission' => ($this->all) ? 'All' : optional($this->permissions)->pluck('display_name'),
'noofuses' => $this->users->count(),
'sort' => $this->sort,
'status' => $this->status,
'id' => $this->id,
'name' => $this->name,
'permission' => ($this->all) ? 'All' : optional($this->permissions)->pluck('display_name'),
'noofuses' => $this->users->count(),
'sort' => $this->sort,
'status' => $this->status,
'registered_at' => $this->created_at->toIso8601String(),
'last_updated_at' => $this->updated_at->toIso8601String(),
];
}
}
......@@ -31,6 +31,8 @@ class PermissionRepository extends BaseRepository
config('access.permissions_table').'.name',
config('access.permissions_table').'.display_name',
config('access.permissions_table').'.sort',
config('access.permissions_table').'.created_at',
config('access.permissions_table').'.updated_at',
]);
}
......
......@@ -50,6 +50,8 @@ class RoleRepository extends BaseRepository
config('access.roles_table').'.all',
config('access.roles_table').'.sort',
config('access.roles_table').'.status',
config('access.roles_table').'.created_at',
config('access.roles_table').'.updated_at',
DB::raw("GROUP_CONCAT( DISTINCT permissions.display_name SEPARATOR '<br/>') as permission_name"),
DB::raw('(SELECT COUNT(role_user.id) FROM role_user LEFT JOIN users ON role_user.user_id = users.id WHERE role_user.role_id = roles.id AND users.deleted_at IS NULL) AS userCount'),
])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment