@@ -50,9 +50,9 @@ discard block |
||
| 50 | 50 | $prefix = $this->argument('prefix'); |
| 51 | 51 | $middleware = $this->argument('middleware'); |
| 52 | 52 | |
| 53 | - $replace_prefix = str_replace('[%_prefix%]',$prefix,File::get(__DIR__.'/../stubs/routes.stub')); |
|
| 53 | + $replace_prefix = str_replace('[%_prefix%]', $prefix, File::get(__DIR__ . '/../stubs/routes.stub')); |
|
| 54 | 54 | |
| 55 | - $replace_middleware = str_replace('[%_middleware%]',$middleware,$replace_prefix); |
|
| 55 | + $replace_middleware = str_replace('[%_middleware%]', $middleware, $replace_prefix); |
|
| 56 | 56 | |
| 57 | 57 | return $replace_middleware; |
| 58 | 58 | } |
@@ -61,6 +61,6 @@ discard block |
||
| 61 | 61 | public function handle() |
| 62 | 62 | { |
| 63 | 63 | $this->info('Route add success'); |
| 64 | - File::append(base_path('routes/web.php'),"\n".$this->content()); |
|
| 64 | + File::append(base_path('routes/web.php'), "\n" . $this->content()); |
|
| 65 | 65 | } |
| 66 | 66 | } |
@@ -60,21 +60,21 @@ discard block |
||
| 60 | 60 | protected function strReplaceRole($fileName) |
| 61 | 61 | { |
| 62 | 62 | $extend = $this->argument('extends'); |
| 63 | - return str_replace('[%extend_to%]',$extend,File::get(__DIR__.'/../stubs/Views/roles/'.$fileName)); |
|
| 63 | + return str_replace('[%extend_to%]', $extend, File::get(__DIR__ . '/../stubs/Views/roles/' . $fileName)); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | protected function strReplacePermission($fileName) |
| 67 | 67 | { |
| 68 | 68 | $extend = $this->argument('extends'); |
| 69 | - return str_replace('[%extend_to%]',$extend,File::get(__DIR__.'/../stubs/Views/permissions/'.$fileName)); |
|
| 69 | + return str_replace('[%extend_to%]', $extend, File::get(__DIR__ . '/../stubs/Views/permissions/' . $fileName)); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | protected function roleViewCreate() |
| 73 | 73 | { |
| 74 | 74 | |
| 75 | - foreach($this->stubsRole['roles'] as $stub) |
|
| 75 | + foreach ($this->stubsRole['roles'] as $stub) |
|
| 76 | 76 | { |
| 77 | - File::put(base_path('resources/views/advancetrust/roles/').str_replace('stub','php',$stub),$this->strReplaceRole($stub)); |
|
| 77 | + File::put(base_path('resources/views/advancetrust/roles/') . str_replace('stub', 'php', $stub), $this->strReplaceRole($stub)); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | } |
@@ -82,16 +82,16 @@ discard block |
||
| 82 | 82 | protected function permissionViewCreate() |
| 83 | 83 | { |
| 84 | 84 | |
| 85 | - foreach($this->stubsPermission['permissions'] as $stub) |
|
| 85 | + foreach ($this->stubsPermission['permissions'] as $stub) |
|
| 86 | 86 | { |
| 87 | - File::put(base_path('resources/views/advancetrust/permissions/').str_replace('stub','php',$stub),$this->strReplacePermission($stub)); |
|
| 87 | + File::put(base_path('resources/views/advancetrust/permissions/') . str_replace('stub', 'php', $stub), $this->strReplacePermission($stub)); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | protected function createMenu() |
| 93 | 93 | { |
| 94 | - File::put(base_path('resources/views/advancetrust/menu/menu.blade.php'),File::get(__DIR__.'/../stubs/Views/menu/menu.blade.stub')); |
|
| 94 | + File::put(base_path('resources/views/advancetrust/menu/menu.blade.php'), File::get(__DIR__ . '/../stubs/Views/menu/menu.blade.stub')); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | public function handle() |
@@ -48,9 +48,9 @@ |
||
| 48 | 48 | protected function controllerViewCreate() |
| 49 | 49 | { |
| 50 | 50 | |
| 51 | - foreach($this->stubsController['controllers'] as $stub) |
|
| 51 | + foreach ($this->stubsController['controllers'] as $stub) |
|
| 52 | 52 | { |
| 53 | - File::put(base_path('app/Http/Controllers/').str_replace('stub','php',$stub),File::get(__DIR__.'/../stubs/Controllers/'.$stub)); |
|
| 53 | + File::put(base_path('app/Http/Controllers/') . str_replace('stub', 'php', $stub), File::get(__DIR__ . '/../stubs/Controllers/' . $stub)); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | } |
@@ -37,8 +37,8 @@ |
||
| 37 | 37 | */ |
| 38 | 38 | protected function getComposerVal() |
| 39 | 39 | { |
| 40 | - $composer = json_decode(File::get(base_path('composer.json')),true); |
|
| 41 | - return $composer['require']['bantenprov/advancetrust']; |
|
| 40 | + $composer = json_decode(File::get(base_path('composer.json')),true); |
|
| 41 | + return $composer['require']['bantenprov/advancetrust']; |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | public function handle() |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | protected function getComposerVal() |
| 39 | 39 | { |
| 40 | - $composer = json_decode(File::get(base_path('composer.json')),true); |
|
| 40 | + $composer = json_decode(File::get(base_path('composer.json')), true); |
|
| 41 | 41 | return $composer['require']['bantenprov/advancetrust']; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | $this->info('================='); |
| 49 | 49 | $this->info('Author : Bantenprov'); |
| 50 | 50 | $this->info('Support Laravel > 5.4.* '); |
| 51 | - $this->info('Version : '.$version); |
|
| 51 | + $this->info('Version : ' . $version); |
|
| 52 | 52 | $this->info('================='); |
| 53 | 53 | } |
| 54 | 54 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | { |
| 21 | 21 | $permissions = Permission::all(); |
| 22 | 22 | |
| 23 | - return view('advancetrust::permissions.permission',compact('permissions')); |
|
| 23 | + return view('advancetrust::permissions.permission', compact('permissions')); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | { |
| 44 | 44 | $name = \Transliteration::clean_filename($request->name); |
| 45 | 45 | $permission = new Permission(); |
| 46 | - $permission->name = strtolower(str_replace('_','-',$name)); |
|
| 46 | + $permission->name = strtolower(str_replace('_', '-', $name)); |
|
| 47 | 47 | $permission->display_name = $request->display_name; |
| 48 | 48 | $permission->description = $request->description; |
| 49 | 49 | $permission->save(); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | { |
| 62 | 62 | $permission = Permission::find($id); |
| 63 | 63 | |
| 64 | - return view('advancetrust::permissions.permissionshow',compact('permission')); |
|
| 64 | + return view('advancetrust::permissions.permissionshow', compact('permission')); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | { |
| 75 | 75 | $permission = Permission::find($id); |
| 76 | 76 | |
| 77 | - return view('advancetrust::permissions.permissionedit',compact('permission')); |
|
| 77 | + return view('advancetrust::permissions.permissionedit', compact('permission')); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | { |
| 89 | 89 | $permission = new Permission(); |
| 90 | 90 | |
| 91 | - $permission->where('id',$id)->update([ |
|
| 91 | + $permission->where('id', $id)->update([ |
|
| 92 | 92 | 'name' => strtolower(\Transliteration::clean_filename($request->name)), |
| 93 | 93 | 'display_name' => $request->display_name, |
| 94 | 94 | 'description' => $request->description, |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | { |
| 22 | 22 | $roles = Role::all(); |
| 23 | 23 | |
| 24 | - return view('advancetrust::roles.role',compact('roles')); |
|
| 24 | + return view('advancetrust::roles.role', compact('roles')); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | { |
| 62 | 62 | $role = Role::find($id); |
| 63 | 63 | |
| 64 | - return view('advancetrust::roles.roleshow',compact('role')); |
|
| 64 | + return view('advancetrust::roles.roleshow', compact('role')); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -74,13 +74,13 @@ discard block |
||
| 74 | 74 | { |
| 75 | 75 | $role = Role::find($id); |
| 76 | 76 | $available_permissions = [0]; |
| 77 | - foreach($role->permissions as $role_permission){ |
|
| 77 | + foreach ($role->permissions as $role_permission) { |
|
| 78 | 78 | $available_permissions[$role_permission->id] = $role_permission->id; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | $permissions = Permission::all(); |
| 82 | 82 | |
| 83 | - return view('advancetrust::roles.addpermission',compact('role','permissions','available_permissions')); |
|
| 83 | + return view('advancetrust::roles.addpermission', compact('role', 'permissions', 'available_permissions')); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -89,19 +89,19 @@ discard block |
||
| 89 | 89 | * @param int $id |
| 90 | 90 | * @return \Illuminate\Http\Response |
| 91 | 91 | */ |
| 92 | - public function storePermission(Request $request,$id) |
|
| 92 | + public function storePermission(Request $request, $id) |
|
| 93 | 93 | { |
| 94 | 94 | |
| 95 | 95 | $role = new Role(); |
| 96 | - $role_permission = $role->where('id',$id)->first()->permissions; |
|
| 96 | + $role_permission = $role->where('id', $id)->first()->permissions; |
|
| 97 | 97 | |
| 98 | - foreach($role_permission as $detachPermission){ |
|
| 99 | - $role->where('id',$id)->first()->detachPermission($detachPermission->id); |
|
| 98 | + foreach ($role_permission as $detachPermission) { |
|
| 99 | + $role->where('id', $id)->first()->detachPermission($detachPermission->id); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - if(count($request->permission) > 0) |
|
| 102 | + if (count($request->permission) > 0) |
|
| 103 | 103 | { |
| 104 | - $role->where('id',$id)->first()->attachPermissions($request->permission); |
|
| 104 | + $role->where('id', $id)->first()->attachPermissions($request->permission); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | { |
| 119 | 119 | $role = Role::find($id); |
| 120 | 120 | |
| 121 | - return view('advancetrust::roles.roleedit',compact('role')); |
|
| 121 | + return view('advancetrust::roles.roleedit', compact('role')); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | { |
| 133 | 133 | $role = new Role(); |
| 134 | 134 | |
| 135 | - $role->where('id',$id)->update([ |
|
| 135 | + $role->where('id', $id)->update([ |
|
| 136 | 136 | 'name' => strtolower(\Transliteration::clean_filename($request->name)), |
| 137 | 137 | 'display_name' => $request->display_name, |
| 138 | 138 | 'description' => $request->description, |
@@ -15,8 +15,8 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | public function boot() |
| 17 | 17 | { |
| 18 | - if(!$this->app->routesAreCached()){ |
|
| 19 | - require __DIR__.'/routes.php'; |
|
| 18 | + if (!$this->app->routesAreCached()) { |
|
| 19 | + require __DIR__ . '/routes.php'; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | // $this->loadViewsFrom(base_path('resources/views/'), 'advancetrust'); |
@@ -4,35 +4,35 @@ discard block |
||
| 4 | 4 | define('COL_DEFAULT', 2); |
| 5 | 5 | |
| 6 | 6 | $fields = [ |
| 7 | - 'author_name' => ['Your name', '', ''], |
|
| 8 | - 'author_github_username' => ['Your Github username', '<username> in https://github.com/username', ''], |
|
| 9 | - 'author_email' => ['Your email address', '', ''], |
|
| 10 | - 'author_twitter' => ['Your twitter username', '', '@{author_github_username}'], |
|
| 11 | - 'author_website' => ['Your website', '', 'https://github.com/{author_github_username}'], |
|
| 7 | + 'author_name' => ['Your name', '', ''], |
|
| 8 | + 'author_github_username' => ['Your Github username', '<username> in https://github.com/username', ''], |
|
| 9 | + 'author_email' => ['Your email address', '', ''], |
|
| 10 | + 'author_twitter' => ['Your twitter username', '', '@{author_github_username}'], |
|
| 11 | + 'author_website' => ['Your website', '', 'https://github.com/{author_github_username}'], |
|
| 12 | 12 | |
| 13 | - 'package_vendor' => ['Package vendor', '<vendor> in https://github.com/vendor/package', '{author_github_username}'], |
|
| 14 | - 'package_name' => ['Package name', '<package> in https://github.com/vendor/package', ''], |
|
| 15 | - 'package_description' => ['Package very short description', '', ''], |
|
| 13 | + 'package_vendor' => ['Package vendor', '<vendor> in https://github.com/vendor/package', '{author_github_username}'], |
|
| 14 | + 'package_name' => ['Package name', '<package> in https://github.com/vendor/package', ''], |
|
| 15 | + 'package_description' => ['Package very short description', '', ''], |
|
| 16 | 16 | |
| 17 | - 'psr4_namespace' => ['PSR-4 namespace', 'usually, Vendor\\Package', '{package_vendor}\\{package_name}'], |
|
| 17 | + 'psr4_namespace' => ['PSR-4 namespace', 'usually, Vendor\\Package', '{package_vendor}\\{package_name}'], |
|
| 18 | 18 | ]; |
| 19 | 19 | |
| 20 | 20 | $values = []; |
| 21 | 21 | |
| 22 | 22 | $replacements = [ |
| 23 | - ':vendor\\\\:package_name\\\\' => function () use(&$values) { return str_replace('\\', '\\\\', $values['psr4_namespace']) . '\\\\'; }, |
|
| 24 | - ':author_name' => function () use(&$values) { return $values['author_name']; }, |
|
| 25 | - ':author_username' => function () use(&$values) { return $values['author_github_username']; }, |
|
| 26 | - ':author_website' => function () use(&$values) { return $values['author_website'] ?: ('https://github.com/' . $values['author_github_username']); }, |
|
| 27 | - ':author_email' => function () use(&$values) { return $values['author_email'] ?: ($values['author_github_username'] . '@example.com'); }, |
|
| 28 | - ':vendor' => function () use(&$values) { return $values['package_vendor']; }, |
|
| 29 | - ':package_name' => function () use(&$values) { return $values['package_name']; }, |
|
| 30 | - ':package_description' => function () use(&$values) { return $values['package_description']; }, |
|
| 31 | - 'League\\Skeleton' => function () use(&$values) { return $values['psr4_namespace']; }, |
|
| 23 | + ':vendor\\\\:package_name\\\\' => function() use(&$values) { return str_replace('\\', '\\\\', $values['psr4_namespace']) . '\\\\'; }, |
|
| 24 | + ':author_name' => function() use(&$values) { return $values['author_name']; }, |
|
| 25 | + ':author_username' => function() use(&$values) { return $values['author_github_username']; }, |
|
| 26 | + ':author_website' => function() use(&$values) { return $values['author_website'] ?: ('https://github.com/' . $values['author_github_username']); }, |
|
| 27 | + ':author_email' => function() use(&$values) { return $values['author_email'] ?: ($values['author_github_username'] . '@example.com'); }, |
|
| 28 | + ':vendor' => function() use(&$values) { return $values['package_vendor']; }, |
|
| 29 | + ':package_name' => function() use(&$values) { return $values['package_name']; }, |
|
| 30 | + ':package_description' => function() use(&$values) { return $values['package_description']; }, |
|
| 31 | + 'League\\Skeleton' => function() use(&$values) { return $values['psr4_namespace']; }, |
|
| 32 | 32 | ]; |
| 33 | 33 | |
| 34 | -function read_from_console ($prompt) { |
|
| 35 | - if ( function_exists('readline') ) { |
|
| 34 | +function read_from_console($prompt) { |
|
| 35 | + if (function_exists('readline')) { |
|
| 36 | 36 | $line = trim(readline($prompt)); |
| 37 | 37 | if (!empty($line)) { |
| 38 | 38 | readline_add_history($line); |
@@ -68,12 +68,12 @@ discard block |
||
| 68 | 68 | echo "Please, provide the following information:\n"; |
| 69 | 69 | echo "----------------------------------------------------------------------\n"; |
| 70 | 70 | foreach ($fields as $f => $field) { |
| 71 | - $default = isset($field[COL_DEFAULT]) ? interpolate($field[COL_DEFAULT], $values): ''; |
|
| 71 | + $default = isset($field[COL_DEFAULT]) ? interpolate($field[COL_DEFAULT], $values) : ''; |
|
| 72 | 72 | $prompt = sprintf( |
| 73 | 73 | '%s%s%s: ', |
| 74 | 74 | $field[COL_DESCRIPTION], |
| 75 | - $field[COL_HELP] ? ' (' . $field[COL_HELP] . ')': '', |
|
| 76 | - $field[COL_DEFAULT] !== '' ? ' [' . $default . ']': '' |
|
| 75 | + $field[COL_HELP] ? ' (' . $field[COL_HELP] . ')' : '', |
|
| 76 | + $field[COL_DEFAULT] !== '' ? ' [' . $default . ']' : '' |
|
| 77 | 77 | ); |
| 78 | 78 | $values[$f] = read_from_console($prompt); |
| 79 | 79 | if (empty($values[$f])) { |