@@ -12,33 +12,52 @@ class Builder
1212
1313 protected $ roleName = '' ;
1414
15- public function rolePermissions (string $ roleName , array $ rolePermissions ): Builder
16- {
15+ protected $ manualPermissions = [];
16+
17+ public function withRolePermissions (
18+ string $ roleName ,
19+ array $ rolePermissions
20+ ): Builder {
1721 $ this ->rolePermissions = $ rolePermissions ;
1822
1923 $ this ->roleName = $ roleName ;
2024
2125 return $ this ;
2226 }
2327
28+ /**
29+ * @param string $key // key can contain dot to indicate nested level
30+ * @param array $permissions
31+ *
32+ * @return $this
33+ */
34+ public function addManualPermission (string $ key , array $ permissions ): Builder
35+ {
36+ $ this ->manualPermissions [$ key ] = $ permissions ;
37+
38+ return $ this ;
39+ }
40+
2441 public function view (): string
2542 {
26- return View::make ('permissions-generator::permission ' ,
43+ return View::make (
44+ 'permission-generator::permission ' ,
2745 [
28- 'routes ' => Permissions::get (),
29- 'roleName ' => $ this ->roleName ,
30- 'rolePermissions ' => $ this ->rolePermissions
46+ 'routes ' => Permissions::make ()-> withManualPermissions ( $ this -> manualPermissions )-> get (),
47+ 'roleName ' => $ this ->roleName ,
48+ 'rolePermissions ' => $ this ->rolePermissions ,
3149 ]
3250 )->render ();
3351 }
3452
3553 /**
36- * @param null $url // role permissions save url
54+ * @param null $url // role permissions save url
3755 *
3856 * @return string
3957 */
4058 public function scripts ($ url = null ): string
4159 {
42- return View::make ('permissions-generator::scripts ' , ['url ' => $ url ])->render ();
60+ return View::make ('permission-generator::scripts ' , ['url ' => $ url ])
61+ ->render ();
4362 }
4463}
0 commit comments