File tree Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " obrainwave/access-tree" ,
33 "description" : " This package allows you to manage user permissions and roles in a database for Laravel project" ,
4+ "version" : " 1.0.0" ,
45 "keywords" : [
56 " obrainwave" ,
67 " laravel" ,
Original file line number Diff line number Diff line change @@ -229,4 +229,39 @@ function checkPermissions(array $permissions) : bool
229229 return true ;
230230 }
231231 return false ;
232+ }
233+
234+ function fetchPermissions (int $ status = null ) : Object
235+ {
236+ if ($ status == null )
237+ {
238+ $ permissions = \Obrainwave \AccessTree \Models \Permission::get ();
239+ }else {
240+ $ permissions = \Obrainwave \AccessTree \Models \Permission::where ('status ' , $ status )->get ();
241+ }
242+
243+ return $ permissions ;
244+ }
245+
246+ function fetchRoles (int $ status = null ) : Object
247+ {
248+ if ($ status == null )
249+ {
250+ $ roles = \Obrainwave \AccessTree \Models \Role::get ();
251+ }else {
252+ $ roles = \Obrainwave \AccessTree \Models \Role::where ('status ' , $ status )->get ();
253+ }
254+
255+ return $ roles ;
256+ }
257+
258+ function fetchUserRoles (int $ user_id ) : Object
259+ {
260+ $ user_roles = $ roles = \Obrainwave \AccessTree \Models \UserRole::where ('user_id ' , $ user_id )->get ();
261+ foreach ($ user_roles as $ role )
262+ {
263+ $ role ['role ' ] = $ role ->role ;
264+ }
265+
266+ return $ user_roles ;
232267}
Original file line number Diff line number Diff line change 77
88use App \Models \User ;
99use Obrainwave \AccessTree \Models \Role ;
10+ use Obrainwave \AccessTree \Models \Permission ;
1011
1112class UserRole extends Model
1213{
You can’t perform that action at this time.
0 commit comments