├── .codeclimate.yml
├── .gitignore
├── .travis.yml
├── CHANGELOG.md
├── LICENSE.md
├── README.md
├── codeception.yml
├── composer.json
├── composer.lock
├── config
└── entrust-gui.php
├── database
└── migrations
│ ├── .gitkeep
│ ├── 2014_10_12_000000_create_users_table.php
│ ├── 2014_10_12_100000_create_password_resets_table.php
│ └── 2015_08_06_174610_entrust_setup_tables.php
├── phpunit.xml
├── src
├── Console
│ └── Commands
│ │ └── GenerateModels.php
├── EntrustGuiServiceProvider.php
├── Events
│ ├── EventInterface.php
│ ├── PermissionCreatedEvent.php
│ ├── PermissionDeletedEvent.php
│ ├── PermissionUpdatedEvent.php
│ ├── RoleCreatedEvent.php
│ ├── RoleDeletedEvent.php
│ ├── RoleUpdatedEvent.php
│ ├── UserCreatedEvent.php
│ ├── UserDeletedEvent.php
│ └── UserUpdatedEvent.php
├── Gateways
│ ├── .gitkeep
│ ├── ManyToManyGateway.php
│ ├── ManyToManyGatewayInterface.php
│ ├── PermissionGateway.php
│ ├── RoleGateway.php
│ └── UserGateway.php
├── Http
│ ├── Controllers
│ │ ├── ManyToManyController.php
│ │ ├── PermissionsController.php
│ │ ├── RolesController.php
│ │ └── UsersController.php
│ ├── Middleware
│ │ └── AdminAuth.php
│ └── routes.php
├── Models
│ ├── Permission.php
│ ├── Role.php
│ └── User.php
├── Repositories
│ ├── .gitkeep
│ ├── ManyToManyRepositoryEloquent.php
│ ├── PermissionRepository.php
│ ├── PermissionRepositoryEloquent.php
│ ├── RoleRepository.php
│ ├── RoleRepositoryEloquent.php
│ ├── UserRepository.php
│ └── UserRepositoryEloquent.php
└── Traits
│ ├── DeleteModelTrait.php
│ ├── FindModelTrait.php
│ ├── GetPermissionModelNameTrait.php
│ ├── GetPermissionUserRelationNameTrait.php
│ ├── GetRoleModelNameTrait.php
│ ├── GetRoleRelationNameTrait.php
│ ├── PaginationGatewayTrait.php
│ ├── SetPermissionModelTrait.php
│ ├── SetRoleModelTrait.php
│ └── SetUserModelTrait.php
├── templates
├── Permission.php.txt
├── Role.php.txt
└── User.php.txt
├── tests
├── .gitkeep
├── TestCase.php
├── _bootstrap.php
├── _data
│ └── dump.sql
├── _support
│ ├── AcceptanceTester.php
│ ├── FunctionalTester.php
│ ├── Helper
│ │ ├── Acceptance.php
│ │ ├── Functional.php
│ │ └── Unit.php
│ ├── UnitTester.php
│ └── _generated
│ │ ├── AcceptanceTesterActions.php
│ │ ├── FunctionalTesterActions.php
│ │ └── UnitTesterActions.php
├── acceptance.suite.yml
├── acceptance
│ └── _bootstrap.php
├── functional.suite.yml
├── functional
│ └── _bootstrap.php
├── unit.suite.yml
└── unit
│ ├── Console
│ └── Commands
│ │ └── GenerateModelsTest.php
│ ├── Gateways
│ ├── PermissionGatewayTest.php
│ ├── RoleGatewayTest.php
│ └── UserGatewayTest.php
│ ├── Http
│ ├── Middleware
│ │ └── AdminAuthTest.php
│ └── RoutesTest.php
│ └── _bootstrap.php
├── translations
├── en
│ ├── button.php
│ ├── flash.php
│ ├── navigation.php
│ ├── permissions.php
│ ├── roles.php
│ └── users.php
├── es
│ ├── button.php
│ ├── flash.php
│ ├── navigation.php
│ ├── permissions.php
│ ├── roles.php
│ └── users.php
└── pt-BR
│ ├── button.php
│ ├── flash.php
│ ├── navigation.php
│ ├── permissions.php
│ ├── roles.php
│ └── users.php
└── views
├── app.blade.php
├── partials
├── navigation.blade.php
└── notifications.blade.php
├── permissions
├── create.blade.php
├── edit.blade.php
├── index.blade.php
└── partials
│ └── form.blade.php
├── roles
├── create.blade.php
├── edit.blade.php
├── index.blade.php
└── partials
│ └── form.blade.php
└── users
├── create.blade.php
├── edit.blade.php
├── index.blade.php
└── partials
└── form.blade.php
/.codeclimate.yml:
--------------------------------------------------------------------------------
1 | languages:
2 | PHP: true
3 | exclude_paths:
4 | - "tests/*"
5 | - "vendor/*"
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /vendor
2 | /node_modules
3 | tests/_data/*
4 | tests/_log/*
5 | .idea
6 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: php
2 |
3 | branches:
4 | only:
5 | - testing
6 | php:
7 | - 5.5
8 | - 5.6
9 | - hhvm
10 |
11 | before_script:
12 | - composer self-update
13 | - composer install --prefer-source --no-interaction --dev
14 |
15 | script: vendor/bin/codecept run
16 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | All notable changes to this project will be documented in this file.
4 | This project adheres to [Semantic Versioning](http://semver.org/).
5 |
6 | ## [Unreleased][unreleased]
7 | ### Changed
8 | - Add user name field to users form
9 |
10 |
11 | ## [0.6.0] - 2016-03-03
12 | ### Changed
13 | - Config option for changing unauthorized redirects
14 |
15 | ## [0.5.0] - 2015-09-13
16 | ### Changed
17 | - Console command for generating model files
18 | - Add TestBench for easier testing
19 |
20 | ## [0.4.0] - 2015-09-06
21 | ### Changed
22 | - Add old input to forms when validation fails.
23 | - Move from [dwightwatson/validating](https://github.com/dwightwatson/validating) to [esensi/model](https://github.com/esensi/model)
24 | - Move password hashing form the package to the ```User``` model.
25 | - Add password confirmation feature
26 | - Fix spacing issues on various button and link elements
27 |
28 | ## [0.3.2] - 2015-09-03
29 | ### Changed
30 | - Refactor gateway classes
31 |
32 | ## [0.3.1] - 2015-09-02
33 | ### Changed
34 | - Remove test directory from codeception
35 | - Move duplicate gateway methods into traits
36 |
37 | ## [0.3.0] - 2015-09-01
38 | ### Changed
39 | - Add Codeception
40 | - Add gateway and middleware tests
41 | - Refactor gateway to inject more dependencies
42 | - Add badges to README.md
43 | - Add route documentation to README.md
44 |
45 | ## [0.2.0] - 2015-08-15
46 | ### Changed
47 | - Add English translations
48 |
49 | ## [0.1.0] - 2015-08-12
50 | ### Changed
51 | - Initial GUI
52 | - Events
53 | - Validation
54 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Entrust GUI
2 |
3 | [](https://codeclimate.com/github/acoustep/entrust-gui)
4 | [](https://travis-ci.org/acoustep/entrust-gui)
5 | [](https://packagist.org/packages/acoustep/entrust-gui)
6 | [](https://packagist.org/packages/acoustep/entrust-gui)
7 | [](https://packagist.org/packages/acoustep/entrust-gui)
8 | [](https://packagist.org/packages/acoustep/entrust-gui)
9 | [](https://ko-fi.com/P5P311GU6)
10 |
11 | Entrust GUI is a Admin Interface that makes the administration of users, roles and permissions easier for the [Entrust](https://github.com/Zizaco/entrust) package.
12 |
13 | This package is currently not for handling authentication, authorisation or registration of users.
14 |
15 | 
16 |
17 | ## Installation
18 |
19 | _For Laravel 5.2 - 5.7 see the [5.2 branch](https://github.com/acoustep/entrust-gui/tree/5.2) for installation details._
20 |
21 | _For Laravel 5.8+ see the [5.8 branch](https://github.com/acoustep/entrust-gui/tree/5.8) for installation details._
22 |
23 | Add the package to your ```composer.json``` file
24 |
25 | ```
26 | "acoustep/entrust-gui": "dev-master"
27 | ```
28 |
29 | Add the service provider to your ```config/app.php``` file
30 |
31 | ```
32 | Acoustep\EntrustGui\EntrustGuiServiceProvider::class,
33 | ```
34 |
35 | Add the Entrust Alias to your ```config/app.php``` file as well.
36 |
37 | ```
38 | 'Entrust' => Zizaco\Entrust\EntrustFacade::class,
39 | ```
40 |
41 | Publish the configuration file(s)
42 |
43 | ```
44 | php artisan vendor:publish --tag="config"
45 | ```
46 |
47 | If you haven't already set up Entrust then make the migration file and run the migration.
48 |
49 | ```
50 | php artisan entrust:migration
51 | php artisan migrate
52 | ```
53 |
54 | Entrust GUI uses [esensi/model](https://github.com/esensi/model) which means you can set your validation rules in your models.
55 |
56 | To generate ```User```, ```Role``` and ```Permission``` models run the ```entrust-gui:models``` command.
57 |
58 | ```
59 | php artisan entrust-gui:models
60 | ```
61 |
62 | See the **manually creating models** section if you prefer to adjust your current model files.
63 |
64 | By default, all three files are published into the ```app_path()``` directory. You can specify the files separately and the location
65 |
66 | Add the Entrust GUI middleware to ```app\Http\Kernal.php```. This middleware will allow users with the role ```admin``` (case sensitive) to access Entrust GUI and deny other users.
67 |
68 | ```
69 | protected $routeMiddleware = [
70 | // ...
71 | 'entrust-gui.admin' => \Acoustep\EntrustGui\Http\Middleware\AdminAuth::class,
72 | ];
73 |
74 | ```
75 |
76 | At this point you're all good to go. See Getting Started for how to use the package.
77 |
78 | ## Getting Started
79 |
80 | ### Accessing Entrust GUI
81 |
82 | By default all routes are prefixed with ```/entrust-gui```.
83 |
84 | * Users: ```/entrust-gui/users```
85 | * Roles: ```/entrust-gui/roles```
86 | * Permissions: ```/entrust-gui/permissions```
87 |
88 | You can change this prefix by editing ```route-prefix``` in ```config/entrust-gui.php```.
89 |
90 | ```
91 | 'route-prefix' => 'admin'
92 | ```
93 |
94 | Pointing your app to ```/entrust-gui/users``` will redirect you to ```/auth/login``` if you are not logged in as admin using the default ```entrust-gui.admin``` middleware.
95 |
96 | If you have not set up Laravel authentication you will see a ```NotFoundHttpException``` exception. See the Laravel [Authentication](http://laravel.com/docs/5.1/authentication) documentation for setting up the Login system in Laravel 5.1.
97 |
98 | ### Middleware
99 |
100 | By default Entrust GUI uses ```entrust-gui.admin``` for middleware. This allows logged in users with the ```admin``` role to access it.
101 |
102 | You can change the middleware in ```config/entrust-gui.php``` in the ```middleware``` setting.
103 |
104 | If you wish to test out the system without middleware then go to ```config/entrust-gui.php``` and set middleware to ```null```.
105 |
106 | ```
107 | 'middleware' => null,
108 | ```
109 |
110 | If you want to change the name of the role that has access to the ```admin``` middleware, update ```middleware-role``` in the configuration file.
111 |
112 | ```
113 | "middleware-role" => 'sudo-admin',
114 | ```
115 |
116 | ### Layout
117 |
118 | To use your own layout override the ```layout``` key in ```config/entrust-gui.php``` with the template you wish to use.
119 |
120 | ```
121 | "layout" => "app", // located in views/app.blade.php
122 | ```
123 |
124 | Each template yields to ```heading``` and ```content``` so make sure your new layout has those sections.
125 |
126 | ```
127 |
128 |
129 |
130 | title
131 |
132 |
133 | @yield('heading')
134 | @include('entrust-gui::partials.notifications')
135 | @yield('content')
136 |
137 |
138 | ```
139 |
140 | ### Editing Templates
141 |
142 | To edit the template files you first need to publish them
143 |
144 | ```
145 | php artisan vendor:publish --tag="views"
146 | ```
147 |
148 | All files are then stored in the ```resources/views/vendor/entrust-gui``` directory.
149 |
150 | ### Routes
151 |
152 | You may wish to link to pages in your own templates. EntrustGUI follows Laravel's ```Route::resource``` method with the exception of ```show```.
153 |
154 | ```
155 | route('entrust-gui::users.index')
156 | route('entrust-gui::users.create')
157 | route('entrust-gui::users.destroy', $id)
158 | route('entrust-gui::users.update', $id)
159 | route('entrust-gui::users.edit', $id)
160 | ```
161 |
162 | ### Events
163 |
164 | The following event classes are available:
165 |
166 | * ```UserCreatedEvent```, ```UserDeletedEvent```, ```UserUpdatedEvent```.
167 | * ```RoleCreatedEvent```, ```RoleDeletedEvent```, ```RoleUpdatedEvent```.
168 | * ```PermissionCreatedEvent```, ```PermissionDeletedEvent```, ```PermissionUpdatedEvent```.
169 |
170 | #### Example Event Listener
171 |
172 | ```
173 | user->email);
203 | }
204 | }
205 | ```
206 |
207 | Add the listeners you need to use to ```app/Providers/EventServiceProvider.php```.
208 |
209 | ```
210 | protected $listen = [
211 | 'Acoustep\EntrustGui\Events\UserCreatedEvent' => [
212 | 'App\Listeners\UserCreatedListener',
213 | ],
214 | 'Acoustep\EntrustGui\Events\UserUpdatedEvent' => [
215 | 'App\Listeners\UserUpdatedListener',
216 | ],
217 | 'Acoustep\EntrustGui\Events\UserDeletedEvent' => [
218 | 'App\Listeners\UserDeletedListener',
219 | ],
220 | 'Acoustep\EntrustGui\Events\RoleCreatedEvent' => [
221 | 'App\Listeners\RoleCreatedListener',
222 | ],
223 | 'Acoustep\EntrustGui\Events\RoleUpdatedEvent' => [
224 | 'App\Listeners\RoleUpdatedListener',
225 | ],
226 | 'Acoustep\EntrustGui\Events\RoleDeletedEvent' => [
227 | 'App\Listeners\RoleDeletedListener',
228 | ],
229 | 'Acoustep\EntrustGui\Events\PermissionCreatedEvent' => [
230 | 'App\Listeners\PermissionCreatedListener',
231 | ],
232 | 'Acoustep\EntrustGui\Events\PermissionUpdatedEvent' => [
233 | 'App\Listeners\PermissionUpdatedListener',
234 | ],
235 | 'Acoustep\EntrustGui\Events\PermissionDeletedEvent' => [
236 | 'App\Listeners\PermissionDeletedListener',
237 | ]
238 | ];
239 | ```
240 |
241 | ### Editing Translations
242 |
243 | Run the publish translation command
244 |
245 | ```
246 | php artisan vendor:publish --tag="translations"
247 | ```
248 |
249 | Translations are then published to ```resources/lang/vendor/entrust-gui```.
250 |
251 | ### Adding Password Confirmation Field to Users
252 |
253 | Update your ```User``` model to the following:
254 |
255 | ```
256 | [
307 | 'email' => 'required|email|unique:users',
308 | 'password' => 'required|confirmed',
309 | ],
310 |
311 | 'updating' => [
312 | 'email' => 'required|email|unique:users',
313 | 'password' => 'confirmed',
314 | ],
315 | ];
316 |
317 | }
318 | ```
319 |
320 | Update ```config/entrust-gui.php```
321 |
322 | ```
323 | 'confirmable' => true,
324 | ```
325 |
326 | ### Generating Models Command Options
327 |
328 | Generating a specific model
329 |
330 | ```
331 | php artisan entrust-gui:models User
332 | ```
333 |
334 | Changing the model directory destination
335 |
336 | ```
337 | php artisan entrust-gui:models --path=new/path
338 | ```
339 |
340 | Skipping confirmation prompts for overwriting existing files
341 |
342 | ```
343 | php artisan entrust-gui:models --force
344 | ```
345 |
346 |
347 | ### Manually Creating Models
348 |
349 | Here are ```User```, ```Role``` and ```Permission``` models. Make sure these parameters are and traits are included for the package to work as intended.
350 |
351 | #### app/User.php
352 |
353 | ```
354 | [
399 | 'email' => 'required|email|unique:users',
400 | 'password' => 'required',
401 | ],
402 |
403 | 'updating' => [
404 | 'email' => 'required|email|unique:users',
405 | 'password' => '',
406 | ],
407 | ];
408 |
409 | }
410 | ```
411 |
412 | #### app/Role.php
413 |
414 | ```
415 | 'required|unique:roles',
435 | 'display_name' => 'required|unique:roles',
436 | ];
437 | }
438 | ```
439 |
440 | #### app/Permission.php
441 |
442 | ```
443 | 'required|unique:permissions',
463 | ];
464 | }
465 | ```
466 | ## Upgrade Guide / Breaking Changes
467 |
468 | ### 0.6
469 |
470 | Includes a new config key, "unauthorized-url" which lets you set the redirection if a user is not authorized. If this key is not found, it will use the old url, /auth/login. The default is set to /auth/login to match Laravel 5.1's documentation on the [authentication routes](https://www.laravel.com/docs/5.1/authentication#included-routing).
471 |
472 | ### 0.3.* to 0.4.0
473 |
474 | Starting from 0.4.0 Entrust GUI switches from ```dwightwatson/validating``` to ```esensi/model```.
475 |
476 | Hashing passwords has moved from the package to the ```User``` model.
477 |
478 | Update your ```User``` model to the one in the latest documentation.
479 |
480 | Add ```'confirmable' => false,``` to your configuration file.
481 |
482 | If you intend to use the confirmable option and have already published the views add the following to your ```resources/views/vendor/entrust-gui/users/partials/form.blade.php``` template
483 |
484 | ```
485 | @if(Config::get('entrust-gui.confirmable') === true)
486 |
487 |
488 |
489 |
490 | @endif
491 | ```
492 |
493 | ## Support Entrust GUI
494 |
495 | Entrust GUI is maintained entirely in my own time. If you'd like to help, please feel free to open an issue with feature requests or proposals. If you'd like to buy me a coffee to say thanks, check out my [ko-fi page](https://ko-fi.com/P5P311GU6).
496 |
497 | ## To do
498 |
499 | * Advanced middleware configuration
500 | * More testing
501 | * More documentation
502 |
--------------------------------------------------------------------------------
/codeception.yml:
--------------------------------------------------------------------------------
1 | actor: Tester
2 | paths:
3 | tests: tests
4 | log: tests/_output
5 | data: tests/_data
6 | support: tests/_support
7 | envs: tests/_envs
8 | settings:
9 | bootstrap: _bootstrap.php
10 | colors: true
11 | memory_limit: 1024M
12 | extensions:
13 | enabled:
14 | - Codeception\Extension\RunFailed
15 | modules:
16 | enabled: [Asserts, Mockery]
17 | config:
18 | Db:
19 | dsn: ''
20 | user: ''
21 | password: ''
22 | dump: tests/_data/dump.sql
23 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "acoustep/entrust-gui",
3 | "description": "A GUI for the Entrust package.",
4 | "keywords": ["laravel","illuminate","auth","roles","acl","permission","gui"],
5 | "homepage": "https://github.com/acoustep/entrust-gui",
6 | "license": "MIT",
7 | "authors": [
8 | {
9 | "name": "Mitch Stanley",
10 | "email": "acoustep+entrustgui@fastmail.co.uk"
11 | }
12 | ],
13 | "require": {
14 | "php": ">=5.5.0",
15 | "illuminate/console": "~5.0",
16 | "illuminate/support": "~5.0",
17 | "zizaco/entrust": "~1.4.0",
18 | "prettus/l5-repository": "^2.1",
19 | "esensi/model": "0.5.*"
20 | },
21 | "require-dev": {
22 | "phpunit/phpunit": "~4.1",
23 | "mockery/mockery": "0.9.*",
24 | "codeception/codeception": "2.1.*",
25 | "codeception/mockery-module": "0.2.*",
26 | "mikey179/vfsStream": "1.5.*",
27 | "symfony/Console": "2.7.*",
28 | "orchestra/testbench": "~3.1",
29 | "aedart/testing-laravel": "1.1.*"
30 | },
31 | "autoload": {
32 | "psr-4": {
33 | "Acoustep\\EntrustGui\\": "src/"
34 | }
35 | },
36 | "autoload-dev": {
37 | "psr-4": {
38 | "Acoustep\\EntrustGui\\Tests\\": "tests/"
39 | }
40 | },
41 | "minimum-stability": "dev"
42 | }
43 |
--------------------------------------------------------------------------------
/config/entrust-gui.php:
--------------------------------------------------------------------------------
1 | "entrust-gui::app",
4 | "route-prefix" => "entrust-gui",
5 | "pagination" => [
6 | "users" => 5,
7 | "roles" => 5,
8 | "permissions" => 5,
9 | ],
10 | "middleware" => 'entrust-gui.admin',
11 | "unauthorized-url" => '/login',
12 | "middleware-role" => 'admin',
13 | "confirmable" => false,
14 | "users" => [
15 | 'deletable' => true,
16 | ],
17 | ];
18 |
--------------------------------------------------------------------------------
/database/migrations/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/acoustep/entrust-gui/ed8120fa8dd658c92650ab050bb6a4f9f2969fc0/database/migrations/.gitkeep
--------------------------------------------------------------------------------
/database/migrations/2014_10_12_000000_create_users_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
17 | $table->string('name');
18 | $table->string('email')->unique();
19 | $table->string('password', 60);
20 | $table->rememberToken();
21 | $table->timestamps();
22 | });
23 | }
24 |
25 | /**
26 | * Reverse the migrations.
27 | *
28 | * @return void
29 | */
30 | public function down()
31 | {
32 | Schema::drop('users');
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/database/migrations/2014_10_12_100000_create_password_resets_table.php:
--------------------------------------------------------------------------------
1 | string('email')->index();
17 | $table->string('token')->index();
18 | $table->timestamp('created_at');
19 | });
20 | }
21 |
22 | /**
23 | * Reverse the migrations.
24 | *
25 | * @return void
26 | */
27 | public function down()
28 | {
29 | Schema::drop('password_resets');
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/database/migrations/2015_08_06_174610_entrust_setup_tables.php:
--------------------------------------------------------------------------------
1 | increments('id');
17 | $table->string('name')->unique();
18 | $table->string('display_name')->nullable();
19 | $table->string('description')->nullable();
20 | $table->timestamps();
21 | });
22 |
23 | // Create table for associating roles to users (Many-to-Many)
24 | Schema::create('role_user', function (Blueprint $table) {
25 | $table->integer('user_id')->unsigned();
26 | $table->integer('role_id')->unsigned();
27 |
28 | $table->foreign('user_id')->references('id')->on('users')
29 | ->onUpdate('cascade')->onDelete('cascade');
30 | $table->foreign('role_id')->references('id')->on('roles')
31 | ->onUpdate('cascade')->onDelete('cascade');
32 |
33 | $table->primary(['user_id', 'role_id']);
34 | });
35 |
36 | // Create table for storing permissions
37 | Schema::create('permissions', function (Blueprint $table) {
38 | $table->increments('id');
39 | $table->string('name')->unique();
40 | $table->string('display_name')->nullable();
41 | $table->string('description')->nullable();
42 | $table->timestamps();
43 | });
44 |
45 | // Create table for associating permissions to roles (Many-to-Many)
46 | Schema::create('permission_role', function (Blueprint $table) {
47 | $table->integer('permission_id')->unsigned();
48 | $table->integer('role_id')->unsigned();
49 |
50 | $table->foreign('permission_id')->references('id')->on('permissions')
51 | ->onUpdate('cascade')->onDelete('cascade');
52 | $table->foreign('role_id')->references('id')->on('roles')
53 | ->onUpdate('cascade')->onDelete('cascade');
54 |
55 | $table->primary(['permission_id', 'role_id']);
56 | });
57 | }
58 |
59 | /**
60 | * Reverse the migrations.
61 | *
62 | * @return void
63 | */
64 | public function down()
65 | {
66 | Schema::drop('permission_role');
67 | Schema::drop('permissions');
68 | Schema::drop('role_user');
69 | Schema::drop('roles');
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 | ./tests/unit/
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/Console/Commands/GenerateModels.php:
--------------------------------------------------------------------------------
1 | option('path')) ? $this->option('path') : app_path()) . '/';
39 | $model = $this->argument('model');
40 | $files = $this->getFiles($model);
41 | foreach ($files as $file) {
42 | $file_path = $path.$file;
43 | if ($this->writeable($file_path)) {
44 | $this->write($file, $file_path);
45 | $this->info($file.' saved to '.$file_path);
46 | }
47 | }
48 | }
49 |
50 | /**
51 | * return the files specified
52 | *
53 | * @param string
54 | *
55 | * @return array
56 | */
57 | protected function getFiles($model = 'All')
58 | {
59 | $files = [
60 | 'Permission' => 'Permission.php',
61 | 'Role' => 'Role.php',
62 | 'User' => 'User.php',
63 | ];
64 | if ($model === 'All') {
65 | return $files;
66 | } else {
67 | return [$model => $files[$model]];
68 | }
69 |
70 | }
71 | /**
72 | * return if the file path is writable
73 | *
74 | * @param string
75 | *
76 | * @return boolean
77 | */
78 | protected function writeable($file_path)
79 | {
80 | if ($this->option('force')) {
81 | return true;
82 | }
83 | return ( ! file_exists($file_path) || $this->confirmable($file_path));
84 | }
85 |
86 | protected function confirmable($file_path)
87 | {
88 | return (file_exists($file_path) && $this->confirm('Overwrite '.$file_path.'? [y|N]'));
89 | }
90 |
91 | /**
92 | * write the file to the file path
93 | *
94 | * @param string
95 | * @param string
96 | *
97 | * @return void
98 | */
99 | protected function write($file, $file_path)
100 | {
101 | if (! is_dir(dirname($file_path))) {
102 | mkdir(dirname($file_path), 0755, true);
103 | }
104 | file_put_contents(
105 | $file_path,
106 | file_get_contents(
107 | dirname(__FILE__)
108 | .DIRECTORY_SEPARATOR
109 | .'..'.DIRECTORY_SEPARATOR
110 | .'..'.DIRECTORY_SEPARATOR
111 | .'..'.DIRECTORY_SEPARATOR
112 | .'templates'
113 | .DIRECTORY_SEPARATOR
114 | .$file
115 | .'.txt'
116 | )
117 | );
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/src/EntrustGuiServiceProvider.php:
--------------------------------------------------------------------------------
1 |
12 | */
13 | class EntrustGuiServiceProvider extends ServiceProvider
14 | {
15 |
16 |
17 | /**
18 | * Indicates if loading of the provider is deferred.
19 | *
20 | * @var bool
21 | */
22 | protected $defer = false;
23 |
24 | /**
25 | * Boot and configure the application paths
26 | *
27 | * @return void
28 | */
29 | public function boot()
30 | {
31 |
32 | $this->loadViewsFrom(realpath(__DIR__.'/../views'), 'entrust-gui');
33 | $this->setupRoutes($this->app->router);
34 | $this->loadTranslationsFrom(realpath(__DIR__.'/../translations'), 'entrust-gui');
35 |
36 |
37 | // This is for conig
38 | $this->publishes(
39 | [__DIR__.'/../config/entrust-gui.php' => config_path('entrust-gui.php')],
40 | 'config'
41 | );
42 |
43 | // This is for views
44 | $this->publishes(
45 | [__DIR__.'/../views' => base_path('resources/views/vendor/entrust-gui')],
46 | 'views'
47 | );
48 |
49 | // This is for translations
50 | $this->publishes(
51 | [__DIR__.'/../translations' => base_path('resources/lang/vendor/entrust-gui')],
52 | 'translations'
53 | );
54 | // Register commands
55 | $this->commands('command.entrust-gui.models');
56 | }
57 |
58 | /**
59 | * Define the routes for the application.
60 | *
61 | * @param \Illuminate\Routing\Router $router
62 | *
63 | * @return void
64 | */
65 | public function setupRoutes(Router $router)
66 | {
67 | $router->group(
68 | ['namespace' => 'Acoustep\EntrustGui\Http\Controllers'],
69 | function ($router) {
70 | include __DIR__.'/Http/routes.php';
71 | }
72 | );
73 | }
74 |
75 | /**
76 | * Register the service provider.
77 | *
78 | * @return void
79 | */
80 | public function register()
81 | {
82 | $this->app->register('Zizaco\Entrust\EntrustServiceProvider');
83 | $this->app->register('Prettus\Repository\Providers\RepositoryServiceProvider');
84 | $this->app->bind(
85 | 'Acoustep\EntrustGui\Repositories\UserRepository',
86 | 'Acoustep\EntrustGui\Repositories\UserRepositoryEloquent'
87 | );
88 | $this->app->bind(
89 | 'Acoustep\EntrustGui\Repositories\RoleRepository',
90 | 'Acoustep\EntrustGui\Repositories\RoleRepositoryEloquent'
91 | );
92 | $this->app->bind(
93 | 'Acoustep\EntrustGui\Repositories\PermissionRepository',
94 | 'Acoustep\EntrustGui\Repositories\PermissionRepositoryEloquent'
95 | );
96 |
97 | $this->registerCommands();
98 | }
99 | /**
100 | * Register commands.
101 | *
102 | * @return void
103 | */
104 | protected function registerCommands()
105 | {
106 | $this->registerGenerateModelsCommand();
107 | }
108 |
109 | /**
110 | * Register the export models command.
111 | *
112 | * @return void
113 | */
114 | protected function registerGenerateModelsCommand()
115 | {
116 | $this->app->singleton('command.entrust-gui.models', function ($app) {
117 | return new GenerateModels();
118 | });
119 | }
120 |
121 | /**
122 | * List of commands provided by the package.
123 | *
124 | * @return void
125 | */
126 | public function provides()
127 | {
128 | return ['command.entrust-gui.models'];
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/src/Events/EventInterface.php:
--------------------------------------------------------------------------------
1 | config = $config;
38 | $this->repository = $repository;
39 | $this->dispatcher = $dispatcher;
40 | }
41 |
42 | /**
43 | * Create a model
44 | *
45 | * @param Illuminate\Http\Request $request
46 | *
47 | * @return Illuminate\Database\Eloquent\Model
48 | */
49 | public function create($request)
50 | {
51 | $model = $this->repository->create($request->all());
52 | $model->{$this->getShortRelationName()}()->sync($request->get($this->getRelationName(), []));
53 | $event_class = "Acoustep\EntrustGui\Events\\".ucwords($this->getModelName()).'CreatedEvent';
54 | $event = new $event_class;
55 | $this->dispatcher->fire($event->setModel($model));
56 | return $model;
57 | }
58 |
59 | /**
60 | * Find model by ID
61 | *
62 | * @param integer $id
63 | *
64 | * @return Illuminate\Database\Eloquent\Model
65 | */
66 | public function find($id)
67 | {
68 | return $this->repository->with($this->getShortRelationName())->find($id);
69 | }
70 |
71 | /**
72 | * Update model
73 | *
74 | * @param Illuminate\Http\Request $request
75 | * @param integer $id
76 | *
77 | * @return Illuminate\Database\Eloquent\Model
78 | */
79 | public function update($request, $id)
80 | {
81 | $model = $this->repository->update($request->all(), $id);
82 | $event_class = "Acoustep\EntrustGui\Events\\".ucwords($this->getModelName()).'UpdatedEvent';
83 | $event = new $event_class;
84 | $this->dispatcher->fire($event->setModel($model));
85 | return $model;
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/src/Gateways/ManyToManyGatewayInterface.php:
--------------------------------------------------------------------------------
1 | config = $config;
46 | $this->repository = $repository;
47 | $role_class = $this->config->get('entrust.role');
48 | $this->role = new $role_class;
49 | $this->dispatcher = $dispatcher;
50 | $this->hash = $hash;
51 | }
52 |
53 | /**
54 | * Create a user
55 | *
56 | * @param Illuminate\Http\Request $request
57 | *
58 | * @return Illuminate\Database\Eloquent\Model
59 | */
60 | public function create($request)
61 | {
62 | $data = $request->all();
63 | $user = $this->repository->create($data);
64 |
65 | $event_class = "Acoustep\EntrustGui\Events\\".ucwords($this->getModelName()).'CreatedEvent';
66 | $event = new $event_class;
67 | $this->dispatcher->fire($event->setModel($user));
68 | return $user;
69 | }
70 |
71 | /**
72 | * Update user
73 | *
74 | * @param Illuminate\Http\Request $request
75 | * @param integer $id
76 | *
77 | * @return Illuminate\Database\Eloquent\Model
78 | */
79 | public function update($request, $id)
80 | {
81 | $data = $request->except('password', 'password_confirmation');
82 | if ($request->has('password')) {
83 | $data['password'] = $request->get('password');
84 | $data['password_confirmation'] = $request->get('password_confirmation');
85 | }
86 | $user = $this->repository->update($data, $id);
87 | $event_class = "Acoustep\EntrustGui\Events\\".ucwords($this->getModelName()).'UpdatedEvent';
88 | $event = new $event_class;
89 | $this->dispatcher->fire($event->setModel($user));
90 | return $user;
91 | }
92 |
93 | /**
94 | * Return model name
95 | *
96 | *
97 | * @return string
98 | */
99 | public function getModelName()
100 | {
101 | return 'user';
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/src/Http/Controllers/ManyToManyController.php:
--------------------------------------------------------------------------------
1 | config = $config;
38 | $this->request = $request;
39 | $this->gateway = $gateway;
40 | $relation_class = $this->config->get('entrust.'.$relation);
41 | $this->relation = new $relation_class;
42 | $this->resource = $resource;
43 | }
44 |
45 | /**
46 | * Display a listing of the resource.
47 | * GET /model
48 | *
49 | * @return Response
50 | */
51 | public function index()
52 | {
53 | $models = $this->gateway->paginate($this->config->get('entrust-gui.pagination.'.$this->resource));
54 |
55 | return view('entrust-gui::'.$this->resource.'.index', compact(
56 | "models"
57 | ));
58 | }
59 |
60 | /**
61 | * Show the form for creating a new resource.
62 | * GET /model/create
63 | *
64 | * @return Response
65 | */
66 | public function create()
67 | {
68 | $model_class = $this->config->get('entrust.'.str_singular($this->resource));
69 | $model = new $model_class;
70 | $relations = $this->relation->lists('name', 'id');
71 |
72 | return view('entrust-gui::'.$this->resource.'.create', compact(
73 | 'model',
74 | 'relations'
75 | ));
76 | }
77 |
78 | /**
79 | * Store a newly created resource in storage.
80 | * POST /model
81 | *
82 | * @return Response
83 | */
84 | public function store()
85 | {
86 | try {
87 | $this->gateway->create($this->request);
88 | } catch (ValidationException $e) {
89 | return back()->withErrors($e->getErrors())->withInput();
90 | }
91 | return redirect(
92 | route(
93 | 'entrust-gui::'.$this->resource.'.index'
94 | )
95 | )->withSuccess(
96 | trans(
97 | 'entrust-gui::'.$this->resource.'.created'
98 | )
99 | );
100 | }
101 |
102 | /**
103 | * Show the form for editing the specified resource.
104 | * GET /model/{id}/edit
105 | *
106 | * @param int $id
107 | *
108 | * @return Response
109 | */
110 | public function edit($id)
111 | {
112 | $model = $this->gateway->find($id);
113 | $relations = $this->relation->lists('name', 'id');
114 |
115 | return view('entrust-gui::'.$this->resource.'.edit', compact(
116 | 'model',
117 | 'relations'
118 | ));
119 | }
120 |
121 | /**
122 | * Update the specified resource in storage.
123 | * PUT /model/{id}
124 | *
125 | * @param int $id
126 | *
127 | * @return Response
128 | */
129 | public function update($id)
130 | {
131 | try {
132 | $role = $this->gateway->update($this->request, $id);
133 | } catch (ValidationException $e) {
134 | return back()->withErrors($e->getErrors())->withInput();
135 | }
136 | return redirect(
137 | route(
138 | 'entrust-gui::'.$this->resource.'.index'
139 | )
140 | )->withSuccess(
141 | trans(
142 | 'entrust-gui::'.$this->resource.'.updated'
143 | )
144 | );
145 | }
146 |
147 | /**
148 | * Remove the specified resource from storage.
149 | * DELETE /model/{id}
150 | *
151 | * @param int $id
152 | *
153 | * @return Response
154 | */
155 | public function destroy($id)
156 | {
157 | $this->gateway->delete($id);
158 | return redirect(
159 | route(
160 | 'entrust-gui::'.$this->resource.'.index'
161 | )
162 | )->withSuccess(
163 | trans(
164 | 'entrust-gui::'.$this->resource.'.destroyed'
165 | )
166 | );
167 | }
168 | }
169 |
--------------------------------------------------------------------------------
/src/Http/Controllers/PermissionsController.php:
--------------------------------------------------------------------------------
1 | config = $config;
36 | $this->request = $request;
37 | $this->gateway = $gateway;
38 | $role_class = $this->config->get('entrust.role');
39 | $this->role = new $role_class;
40 | }
41 |
42 | /**
43 | * Display a listing of the resource.
44 | * GET /roles
45 | *
46 | * @return Response
47 | */
48 | public function index()
49 | {
50 | $users = $this->gateway->paginate($this->config->get('entrust-gui.pagination.users'));
51 |
52 | return view(
53 | 'entrust-gui::users.index',
54 | compact(
55 | 'users'
56 | )
57 | );
58 | }
59 |
60 | /**
61 | * Show the form for creating a new resource.
62 | * GET /roles/create
63 | *
64 | * @return Response
65 | */
66 | public function create()
67 | {
68 | $user_class = $this->config->get('auth.model');
69 | $user = new $user_class;
70 | $roles = $this->role->lists('name', 'id');
71 |
72 | return view(
73 | 'entrust-gui::users.create',
74 | compact(
75 | 'user',
76 | 'roles'
77 | )
78 | );
79 | }
80 |
81 | /**
82 | * Store a newly created resource in storage.
83 | * POST /roles
84 | *
85 | * @return Response
86 | */
87 | public function store()
88 | {
89 | try {
90 | $user = $this->gateway->create($this->request);
91 | } catch (ValidationException $e) {
92 | return redirect(route('entrust-gui::users.create'))
93 | ->withErrors($e->getErrors())
94 | ->withInput();
95 | }
96 | return redirect(route('entrust-gui::users.index'))
97 | ->withSuccess(trans('entrust-gui::users.created'));
98 |
99 | }
100 |
101 | /**
102 | * Show the form for editing the specified resource.
103 | * GET /roles/{id}/edit
104 | *
105 | * @param int $id
106 | *
107 | * @return Response
108 | */
109 | public function edit($id)
110 | {
111 | $user = $this->gateway->find($id);
112 | $roles = $this->role->lists('name', 'id');
113 |
114 | return view(
115 | 'entrust-gui::users.edit',
116 | compact(
117 | 'user',
118 | 'roles'
119 | )
120 | );
121 |
122 | }
123 |
124 | /**
125 | * Update the specified resource in storage.
126 | * PUT /roles/{id}
127 | *
128 | * @param int $id
129 | *
130 | * @return Response
131 | */
132 | public function update($id)
133 | {
134 | try {
135 | $this->gateway->update($this->request, $id);
136 | } catch (ValidationException $e) {
137 | return back()->withErrors($e->getErrors())->withInput();
138 | }
139 | return redirect(route('entrust-gui::users.index'))
140 | ->withSuccess(trans('entrust-gui::users.updated'));
141 | }
142 |
143 | /**
144 | * Remove the specified resource from storage.
145 | * DELETE /roles/{id}
146 | *
147 | * @param int $id
148 | *
149 | * @return Response
150 | */
151 | public function destroy($id)
152 | {
153 | if (!config('entrust-gui.users.deletable')) {
154 | abort(404);
155 | }
156 | $this->gateway->delete($id);
157 | return redirect(route('entrust-gui::users.index'))
158 | ->withSuccess(trans('entrust-gui::users.destroyed'));
159 | }
160 | }
161 |
--------------------------------------------------------------------------------
/src/Http/Middleware/AdminAuth.php:
--------------------------------------------------------------------------------
1 | auth = $auth;
36 | $this->config = $config;
37 | $this->response = $response;
38 | $this->redirect = $redirect;
39 | }
40 |
41 | /**
42 | * Handle the request
43 | *
44 | * @param mixed $request
45 | * @param Closure $next
46 | *
47 | * @return Response
48 | */
49 | public function handle($request, Closure $next)
50 | {
51 | if ($this->auth->guest()) {
52 | if ($request->ajax()) {
53 | return $this->response->make('Unauthorized.', 401);
54 | } else {
55 | return $this->redirect->guest($this->config->get('entrust-gui.unauthorized-url', 'auth/login'));
56 | }
57 | } elseif (! $request->user()->hasRole($this->config->get('entrust-gui.middleware-role'))) {
58 | return $this->response->make('Unauthorized.', 401); //Or redirect() or whatever you want
59 | }
60 | return $next($request);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/Http/routes.php:
--------------------------------------------------------------------------------
1 | Config::get("entrust-gui.route-prefix"),
5 | 'middleware' => Config::get("entrust-gui.middleware")
6 | ],
7 | function () {
8 | Route::get('users', ['uses' => 'UsersController@index', 'as' => 'entrust-gui::users.index']);
9 | Route::get('users/create', ['uses' => 'UsersController@create', 'as' => 'entrust-gui::users.create']);
10 | Route::post('users', ['uses' => 'UsersController@store', 'as' => 'entrust-gui::users.store']);
11 | Route::get('users/{id}/edit', ['uses' => 'UsersController@edit', 'as' => 'entrust-gui::users.edit']);
12 | Route::put('users/{id}', ['uses' => 'UsersController@update', 'as' => 'entrust-gui::users.update']);
13 | Route::delete('users/{id}', ['uses' => 'UsersController@destroy', 'as' => 'entrust-gui::users.destroy']);
14 |
15 | Route::get('roles', ['uses' => 'RolesController@index', 'as' => 'entrust-gui::roles.index']);
16 | Route::get('roles/create', ['uses' => 'RolesController@create', 'as' => 'entrust-gui::roles.create']);
17 | Route::post('roles', ['uses' => 'RolesController@store', 'as' => 'entrust-gui::roles.store']);
18 | Route::get('roles/{id}/edit', ['uses' => 'RolesController@edit', 'as' => 'entrust-gui::roles.edit']);
19 | Route::put('roles/{id}', ['uses' => 'RolesController@update', 'as' => 'entrust-gui::roles.update']);
20 | Route::delete('roles/{id}', ['uses' => 'RolesController@destroy', 'as' => 'entrust-gui::roles.destroy']);
21 |
22 | Route::get('permissions', ['uses' => 'PermissionsController@index', 'as' => 'entrust-gui::permissions.index']);
23 | Route::get(
24 | 'permissions/create',
25 | [
26 | 'uses' => 'PermissionsController@create',
27 | 'as' => 'entrust-gui::permissions.create'
28 | ]
29 | );
30 | Route::post('permissions', ['uses' => 'PermissionsController@store', 'as' => 'entrust-gui::permissions.store']);
31 | Route::get(
32 | 'permissions/{id}/edit',
33 | [
34 | 'uses' => 'PermissionsController@edit',
35 | 'as' => 'entrust-gui::permissions.edit'
36 | ]
37 | );
38 | Route::put(
39 | 'permissions/{id}',
40 | [
41 | 'uses' => 'PermissionsController@update',
42 | 'as' => 'entrust-gui::permissions.update'
43 | ]
44 | );
45 | Route::delete(
46 | 'permissions/{id}',
47 | [
48 | 'uses' => 'PermissionsController@destroy',
49 | 'as' => 'entrust-gui::permissions.destroy'
50 | ]
51 | );
52 |
53 | }
54 | );
55 |
--------------------------------------------------------------------------------
/src/Models/Permission.php:
--------------------------------------------------------------------------------
1 | 'required|unique:permissions',
21 | ];
22 | }
23 |
--------------------------------------------------------------------------------
/src/Models/Role.php:
--------------------------------------------------------------------------------
1 | 'required|unique:roles',
21 | 'display_name' => 'required|unique:roles',
22 | ];
23 | }
24 |
--------------------------------------------------------------------------------
/src/Models/User.php:
--------------------------------------------------------------------------------
1 | [
46 | 'email' => 'required|email|unique:users',
47 | 'password' => 'required',
48 | ],
49 |
50 | 'updating' => [
51 | 'email' => 'required|email|unique:users',
52 | 'password' => '',
53 | ],
54 | ];
55 | }
56 |
--------------------------------------------------------------------------------
/src/Repositories/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/acoustep/entrust-gui/ed8120fa8dd658c92650ab050bb6a4f9f2969fc0/src/Repositories/.gitkeep
--------------------------------------------------------------------------------
/src/Repositories/ManyToManyRepositoryEloquent.php:
--------------------------------------------------------------------------------
1 | getModelName());
27 | }
28 |
29 |
30 | /**
31 | * Boot up the repository, pushing criteria
32 | */
33 | public function boot()
34 | {
35 | $this->pushCriteria(app(RequestCriteria::class));
36 | }
37 |
38 | /**
39 | * Update attributes
40 | *
41 | * @param array $attributes
42 | * @param integer $id
43 | *
44 | * @return Model
45 | */
46 | public function update(array $attributes, $id)
47 | {
48 | $defaults = ["{$this->getRelationName()}" => []];
49 | $attributes = array_merge($defaults, $attributes);
50 | $model = parent::update($attributes, $id);
51 | $model->{$this->getShortRelationName()}()->sync($attributes["{$this->getRelationName()}"]);
52 | return $this->parserResult($model);
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/Repositories/PermissionRepository.php:
--------------------------------------------------------------------------------
1 | pushCriteria(app(RequestCriteria::class));
35 | }
36 |
37 | /**
38 | * Create model
39 | *
40 | * @param array $attributes
41 | *
42 | * @return Model
43 | */
44 | public function create(array $attributes)
45 | {
46 | $defaults = ['roles' => []];
47 | $attributes = array_merge($defaults, $attributes);
48 | $model = parent::create($attributes);
49 | if (! in_array('Esensi\Model\Contracts\HashingModelInterface', class_implements($model))) {
50 | throw new Exception(
51 | "User model must implement Esensi\Model\Contracts\HashingModelInterface.
52 | Revert to 0.3.* or see upgrade guide for details."
53 | );
54 | }
55 | $model->roles()->sync($attributes['roles']);
56 | return $this->parserResult($model);
57 | }
58 |
59 | /**
60 | * Update attributes
61 | *
62 | * @param array $attributes
63 | * @param integer $id
64 | *
65 | * @return Model
66 | */
67 | public function update(array $attributes, $id)
68 | {
69 | $defaults = ['roles' => []];
70 | $attributes = array_merge($defaults, $attributes);
71 | $model = $this->find($id);
72 | if (! in_array('Esensi\Model\Contracts\HashingModelInterface', class_implements($model))) {
73 | throw new Exception(
74 | "User model must implement Esensi\Model\Contracts\HashingModelInterface.
75 | Revert to 0.3.* or see upgrade guide for details."
76 | );
77 | }
78 | if (! array_key_exists('password', $attributes)) {
79 | $model->fill($attributes);
80 | if (Config::get('entrust-gui.confirmable') === true) {
81 | $model->password_confirmation = $model->password;
82 | }
83 | $model->saveWithoutHashing();
84 | } else {
85 | $model = parent::update($attributes, $id);
86 | }
87 | $model->roles()->sync($attributes['roles']);
88 | return $this->parserResult($model);
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/src/Traits/DeleteModelTrait.php:
--------------------------------------------------------------------------------
1 | repository->find($id);
16 | $this->repository->delete($id);
17 | $event_class = "Acoustep\EntrustGui\Events\\".ucwords($this->getModelName()).'DeletedEvent';
18 | $event = new $event_class;
19 | $this->dispatcher->fire($event->setModel($model));
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/Traits/FindModelTrait.php:
--------------------------------------------------------------------------------
1 | repository->with($this->getShortRelationName())->find($id);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Traits/GetPermissionModelNameTrait.php:
--------------------------------------------------------------------------------
1 | repository->paginate($take);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Traits/SetPermissionModelTrait.php:
--------------------------------------------------------------------------------
1 | permission = $model;
18 | return $this;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Traits/SetRoleModelTrait.php:
--------------------------------------------------------------------------------
1 | role = $model;
18 | return $this;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Traits/SetUserModelTrait.php:
--------------------------------------------------------------------------------
1 | user = $model;
18 | return $this;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/templates/Permission.php.txt:
--------------------------------------------------------------------------------
1 | 'required|unique:permissions',
21 | ];
22 | }
23 |
--------------------------------------------------------------------------------
/templates/Role.php.txt:
--------------------------------------------------------------------------------
1 | 'required|unique:roles',
21 | 'display_name' => 'required|unique:roles',
22 | ];
23 | }
24 |
--------------------------------------------------------------------------------
/templates/User.php.txt:
--------------------------------------------------------------------------------
1 | [
46 | 'email' => 'required|email|unique:users',
47 | 'password' => 'required',
48 | ],
49 |
50 | 'updating' => [
51 | 'email' => 'required|email|unique:users',
52 | 'password' => '',
53 | ],
54 | ];
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/tests/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/acoustep/entrust-gui/ed8120fa8dd658c92650ab050bb6a4f9f2969fc0/tests/.gitkeep
--------------------------------------------------------------------------------
/tests/TestCase.php:
--------------------------------------------------------------------------------
1 |
15 | */
16 | abstract class TestCase extends BaseTestCase
17 | {
18 | /* ------------------------------------------------------------------------------------------------
19 | | Properties
20 | | ------------------------------------------------------------------------------------------------
21 | */
22 | /** @var array */
23 |
24 | protected static $locales = ['en'];
25 |
26 | /* ------------------------------------------------------------------------------------------------
27 | | Main functions
28 | | ------------------------------------------------------------------------------------------------
29 | */
30 | public static function setUpBeforeClass()
31 | {
32 | parent::setUpBeforeClass();
33 | }
34 |
35 | public static function tearDownAfterClass()
36 | {
37 | parent::tearDownAfterClass();
38 | }
39 |
40 | /* ------------------------------------------------------------------------------------------------
41 | | Bench Functions
42 | | ------------------------------------------------------------------------------------------------
43 | */
44 | /**
45 | * Get package providers.
46 | *
47 | * @param Application $app
48 | *
49 | * @return array
50 | */
51 | protected function getPackageProviders($app)
52 | {
53 | return [
54 | 'Acoustep\\EntrustGui\\EntrustGuiServiceProvider'
55 | ];
56 | }
57 |
58 | /**
59 | * Get package aliases.
60 | *
61 | * @param Application $app
62 | *
63 | * @return array
64 | */
65 | protected function getPackageAliases($app)
66 | {
67 | return [
68 | ];
69 | }
70 |
71 | /**
72 | * Define environment setup.
73 | *
74 | * @param Application $app
75 | */
76 | protected function getEnvironmentSetUp($app)
77 | {
78 | $app['path.storage'] = __DIR__ . '/fixtures';
79 | $app['config']->set('database.default', 'testbench');
80 | $app['config']->set('database.connections.testbench', [
81 | 'driver' => 'sqlite',
82 | 'database' => ':memory:',
83 | 'prefix' => '',
84 | ]);
85 | $app['config']->set('auth.model', 'Acoustep\EntrustGui\Models\User');
86 | $app['config']->set('entrust.role', 'Acoustep\EntrustGui\Models\Role');
87 | $app['config']->set('entrust.permission', 'Acoustep\EntrustGui\Models\Permission');
88 | $app['config']->set('entrust-gui.layout', 'entrust-gui::app');
89 | $app['config']->set('entrust-gui.route-prefix', 'entrust-gui');
90 | $app['config']->set('entrust-gui.confirmable', false);
91 |
92 | $this->registerRoutes($app['router']);
93 | }
94 |
95 | /* ------------------------------------------------------------------------------------------------
96 | | Custom assertions
97 | | ------------------------------------------------------------------------------------------------
98 | */
99 |
100 |
101 | /* ------------------------------------------------------------------------------------------------
102 | | Other Functions
103 | | ------------------------------------------------------------------------------------------------
104 | */
105 | /**
106 | * Get Illuminate Filesystem
107 | *
108 | * @return \Illuminate\Filesystem\Filesystem
109 | */
110 | public function illuminateFile()
111 | {
112 | return app('files');
113 | }
114 |
115 | /**
116 | * Get Filesystem utility
117 | *
118 | * @return \Arcanedev\LogViewer\Utilities\Filesystem
119 | */
120 | protected function filesystem()
121 | {
122 | return app('acoustep.entrust-gui.filesystem');
123 | }
124 |
125 | /**
126 | * Get translator repository
127 | *
128 | * @return \Illuminate\Translation\Translator
129 | */
130 | protected function trans()
131 | {
132 | return $this->app['translator'];
133 | }
134 |
135 | /**
136 | * Get config repository
137 | *
138 | * @return \Illuminate\Config\Repository
139 | */
140 | protected function config()
141 | {
142 | $this->app['config']['auth']['model'] = 'Acoustep\EntrustGui\Models\User';
143 | $this->app['config']['entrust']['role'] = 'Acoustep\EntrustGui\Models\Role';
144 | $this->app['config']['entrust']['role'] = 'Acoustep\EntrustGui\Models\Permission';
145 | return $this->app['config'];
146 | }
147 |
148 | /**
149 | * Get config path
150 | *
151 | * @return string
152 | */
153 | protected function getConfigPath()
154 | {
155 | return realpath(config_path());
156 | }
157 |
158 | /**
159 | * Register all routes
160 | *
161 | * @param Router $router
162 | */
163 | private function registerRoutes(Router $router)
164 | {
165 | $router->group([
166 | 'namespace' => 'Acoustep\\EntrustGui\\Http\\Controllers'
167 | ], function(Router $router) {
168 | $router->group([
169 | 'prefix' => 'entrust-gui',
170 | 'middleware' => null,
171 | ], function(Router $router) {
172 | $router->get('users', ['uses' => 'UsersController@index', 'as' => 'entrust-gui::users.index']);
173 | $router->get('users/create', ['uses' => 'UsersController@create', 'as' => 'entrust-gui::users.create']);
174 | $router->post('users', ['uses' => 'UsersController@store', 'as' => 'entrust-gui::users.store']);
175 | $router->get('users/{id}/edit', ['uses' => 'UsersController@edit', 'as' => 'entrust-gui::users.edit']);
176 | $router->put('users/{id}', ['uses' => 'UsersController@update', 'as' => 'entrust-gui::users.update']);
177 | $router->delete('users/{id}', ['uses' => 'UsersController@destroy', 'as' => 'entrust-gui::users.destroy']);
178 |
179 | $router->get('roles', ['uses' => 'RolesController@index', 'as' => 'entrust-gui::roles.index']);
180 | $router->get('roles/create', ['uses' => 'RolesController@create', 'as' => 'entrust-gui::roles.create']);
181 | $router->post('roles', ['uses' => 'RolesController@store', 'as' => 'entrust-gui::roles.store']);
182 | $router->get('roles/{id}/edit', ['uses' => 'RolesController@edit', 'as' => 'entrust-gui::roles.edit']);
183 | $router->put('roles/{id}', ['uses' => 'RolesController@update', 'as' => 'entrust-gui::roles.update']);
184 | $router->delete('roles/{id}', ['uses' => 'RolesController@destroy', 'as' => 'entrust-gui::roles.destroy']);
185 |
186 | $router->get('permissions', ['uses' => 'PermissionsController@index', 'as' => 'entrust-gui::permissions.index']);
187 | $router->get(
188 | 'permissions/create',
189 | [
190 | 'uses' => 'PermissionsController@create',
191 | 'as' => 'entrust-gui::permissions.create'
192 | ]
193 | );
194 | $router->post('permissions', ['uses' => 'PermissionsController@store', 'as' => 'entrust-gui::permissions.store']);
195 | $router->get(
196 | 'permissions/{id}/edit',
197 | [
198 | 'uses' => 'PermissionsController@edit',
199 | 'as' => 'entrust-gui::permissions.edit'
200 | ]
201 | );
202 | $router->put(
203 | 'permissions/{id}',
204 | [
205 | 'uses' => 'PermissionsController@update',
206 | 'as' => 'entrust-gui::permissions.update'
207 | ]
208 | );
209 | $router->delete(
210 | 'permissions/{id}',
211 | [
212 | 'uses' => 'PermissionsController@destroy',
213 | 'as' => 'entrust-gui::permissions.destroy'
214 | ]
215 | );
216 | });
217 | });
218 | }
219 | }
220 |
--------------------------------------------------------------------------------
/tests/_bootstrap.php:
--------------------------------------------------------------------------------
1 | getScenario()->runStep(new \Codeception\Step\Action('assertEquals', func_get_args()));
33 | }
34 |
35 |
36 | /**
37 | * [!] Method is generated. Documentation taken from corresponding module.
38 | *
39 | * Checks that two variables are not equal
40 | *
41 | * @param $expected
42 | * @param $actual
43 | * @param string $message
44 | * @see \Codeception\Module\Asserts::assertNotEquals()
45 | */
46 | public function assertNotEquals($expected, $actual, $message = null) {
47 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEquals', func_get_args()));
48 | }
49 |
50 |
51 | /**
52 | * [!] Method is generated. Documentation taken from corresponding module.
53 | *
54 | * Checks that two variables are same
55 | *
56 | * @param $expected
57 | * @param $actual
58 | * @param string $message
59 | *
60 | * @return mixed
61 | * @see \Codeception\Module\Asserts::assertSame()
62 | */
63 | public function assertSame($expected, $actual, $message = null) {
64 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertSame', func_get_args()));
65 | }
66 |
67 |
68 | /**
69 | * [!] Method is generated. Documentation taken from corresponding module.
70 | *
71 | * Checks that two variables are not same
72 | *
73 | * @param $expected
74 | * @param $actual
75 | * @param string $message
76 | * @see \Codeception\Module\Asserts::assertNotSame()
77 | */
78 | public function assertNotSame($expected, $actual, $message = null) {
79 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotSame', func_get_args()));
80 | }
81 |
82 |
83 | /**
84 | * [!] Method is generated. Documentation taken from corresponding module.
85 | *
86 | * Checks that actual is greater than expected
87 | *
88 | * @param $expected
89 | * @param $actual
90 | * @param string $message
91 | * @see \Codeception\Module\Asserts::assertGreaterThan()
92 | */
93 | public function assertGreaterThan($expected, $actual, $message = null) {
94 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThan', func_get_args()));
95 | }
96 |
97 |
98 | /**
99 | * [!] Method is generated. Documentation taken from corresponding module.
100 | *
101 | * @deprecated
102 | * @see \Codeception\Module\Asserts::assertGreaterThen()
103 | */
104 | public function assertGreaterThen($expected, $actual, $message = null) {
105 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThen', func_get_args()));
106 | }
107 |
108 |
109 | /**
110 | * [!] Method is generated. Documentation taken from corresponding module.
111 | *
112 | * Checks that actual is greater or equal than expected
113 | *
114 | * @param $expected
115 | * @param $actual
116 | * @param string $message
117 | * @see \Codeception\Module\Asserts::assertGreaterThanOrEqual()
118 | */
119 | public function assertGreaterThanOrEqual($expected, $actual, $message = null) {
120 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThanOrEqual', func_get_args()));
121 | }
122 |
123 |
124 | /**
125 | * [!] Method is generated. Documentation taken from corresponding module.
126 | *
127 | * @deprecated
128 | * @see \Codeception\Module\Asserts::assertGreaterThenOrEqual()
129 | */
130 | public function assertGreaterThenOrEqual($expected, $actual, $message = null) {
131 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThenOrEqual', func_get_args()));
132 | }
133 |
134 |
135 | /**
136 | * [!] Method is generated. Documentation taken from corresponding module.
137 | *
138 | * Checks that actual is less than expected
139 | *
140 | * @param $expected
141 | * @param $actual
142 | * @param string $message
143 | * @see \Codeception\Module\Asserts::assertLessThan()
144 | */
145 | public function assertLessThan($expected, $actual, $message = null) {
146 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessThan', func_get_args()));
147 | }
148 |
149 |
150 | /**
151 | * [!] Method is generated. Documentation taken from corresponding module.
152 | *
153 | * Checks that actual is less or equal than expected
154 | *
155 | * @param $expected
156 | * @param $actual
157 | * @param string $message
158 | * @see \Codeception\Module\Asserts::assertLessThanOrEqual()
159 | */
160 | public function assertLessThanOrEqual($expected, $actual, $message = null) {
161 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessThanOrEqual', func_get_args()));
162 | }
163 |
164 |
165 | /**
166 | * [!] Method is generated. Documentation taken from corresponding module.
167 | *
168 | * Checks that haystack contains needle
169 | *
170 | * @param $needle
171 | * @param $haystack
172 | * @param string $message
173 | * @see \Codeception\Module\Asserts::assertContains()
174 | */
175 | public function assertContains($needle, $haystack, $message = null) {
176 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertContains', func_get_args()));
177 | }
178 |
179 |
180 | /**
181 | * [!] Method is generated. Documentation taken from corresponding module.
182 | *
183 | * Checks that haystack doesn't contain needle.
184 | *
185 | * @param $needle
186 | * @param $haystack
187 | * @param string $message
188 | * @see \Codeception\Module\Asserts::assertNotContains()
189 | */
190 | public function assertNotContains($needle, $haystack, $message = null) {
191 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotContains', func_get_args()));
192 | }
193 |
194 |
195 | /**
196 | * [!] Method is generated. Documentation taken from corresponding module.
197 | *
198 | * Checks that variable is empty.
199 | *
200 | * @param $actual
201 | * @param string $message
202 | * @see \Codeception\Module\Asserts::assertEmpty()
203 | */
204 | public function assertEmpty($actual, $message = null) {
205 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEmpty', func_get_args()));
206 | }
207 |
208 |
209 | /**
210 | * [!] Method is generated. Documentation taken from corresponding module.
211 | *
212 | * Checks that variable is not empty.
213 | *
214 | * @param $actual
215 | * @param string $message
216 | * @see \Codeception\Module\Asserts::assertNotEmpty()
217 | */
218 | public function assertNotEmpty($actual, $message = null) {
219 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEmpty', func_get_args()));
220 | }
221 |
222 |
223 | /**
224 | * [!] Method is generated. Documentation taken from corresponding module.
225 | *
226 | * Checks that variable is NULL
227 | *
228 | * @param $actual
229 | * @param string $message
230 | * @see \Codeception\Module\Asserts::assertNull()
231 | */
232 | public function assertNull($actual, $message = null) {
233 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNull', func_get_args()));
234 | }
235 |
236 |
237 | /**
238 | * [!] Method is generated. Documentation taken from corresponding module.
239 | *
240 | * Checks that variable is not NULL
241 | *
242 | * @param $actual
243 | * @param string $message
244 | * @see \Codeception\Module\Asserts::assertNotNull()
245 | */
246 | public function assertNotNull($actual, $message = null) {
247 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotNull', func_get_args()));
248 | }
249 |
250 |
251 | /**
252 | * [!] Method is generated. Documentation taken from corresponding module.
253 | *
254 | * Checks that condition is positive.
255 | *
256 | * @param $condition
257 | * @param string $message
258 | * @see \Codeception\Module\Asserts::assertTrue()
259 | */
260 | public function assertTrue($condition, $message = null) {
261 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertTrue', func_get_args()));
262 | }
263 |
264 |
265 | /**
266 | * [!] Method is generated. Documentation taken from corresponding module.
267 | *
268 | * Checks that condition is negative.
269 | *
270 | * @param $condition
271 | * @param string $message
272 | * @see \Codeception\Module\Asserts::assertFalse()
273 | */
274 | public function assertFalse($condition, $message = null) {
275 | return $this->getScenario()->runStep(new \Codeception\Step\Action('assertFalse', func_get_args()));
276 | }
277 |
278 |
279 | /**
280 | * [!] Method is generated. Documentation taken from corresponding module.
281 | *
282 | * Fails the test with message.
283 | *
284 | * @param $message
285 | * @see \Codeception\Module\Asserts::fail()
286 | */
287 | public function fail($message) {
288 | return $this->getScenario()->runStep(new \Codeception\Step\Action('fail', func_get_args()));
289 | }
290 | }
291 |
--------------------------------------------------------------------------------
/tests/acceptance.suite.yml:
--------------------------------------------------------------------------------
1 | # Codeception Test Suite Configuration
2 | #
3 | # Suite for acceptance tests.
4 | # Perform tests in browser using the WebDriver or PhpBrowser.
5 | # If you need both WebDriver and PHPBrowser tests - create a separate suite.
6 |
7 | class_name: AcceptanceTester
8 | modules:
9 | enabled:
10 | - PhpBrowser:
11 | url: http://localhost/myapp
12 | - \Helper\Acceptance
--------------------------------------------------------------------------------
/tests/acceptance/_bootstrap.php:
--------------------------------------------------------------------------------
1 | root = vfsStream::setup();
23 | }
24 |
25 | /**
26 | * @test
27 | */
28 | public function generate_with_default_params()
29 | {
30 | $command = $this->artisan('entrust-gui:models', [
31 | '--path' => $this->root->url(),
32 | '--force' => 'true',
33 | ]);
34 | $this->assertTrue($this->root->hasChild('User.php'));
35 | $this->assertTrue($this->root->hasChild('Permission.php'));
36 | $this->assertTrue($this->root->hasChild('Role.php'));
37 | }
38 |
39 | /**
40 | * @test
41 | */
42 | public function generate_specific_model()
43 | {
44 | $command = $this->artisan('entrust-gui:models', [
45 | 'model' => 'User',
46 | '--path' => $this->root->url(),
47 | '--force' => 'true',
48 | ]);
49 | $this->assertTrue($this->root->hasChild('User.php'));
50 | $this->assertFalse($this->root->hasChild('Permission.php'));
51 | $this->assertFalse($this->root->hasChild('Role.php'));
52 | }
53 |
54 | /**
55 | * @test
56 | */
57 | public function generate_specific_path()
58 | {
59 | $command = $this->artisan('entrust-gui:models', [
60 | '--path' => $this->root->url().'/models',
61 | '--force' => 'true',
62 | ]);
63 | $this->assertTrue($this->root->hasChild('models/User.php'));
64 | $this->assertTrue($this->root->hasChild('models/Permission.php'));
65 | $this->assertTrue($this->root->hasChild('models/Role.php'));
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/tests/unit/Gateways/PermissionGatewayTest.php:
--------------------------------------------------------------------------------
1 | config = m::mock('Illuminate\Config\Repository');
21 | $this->repository = m::mock('Acoustep\EntrustGui\Repositories\PermissionRepository, Prettus\Repository\Eloquent\BaseRepository');
22 | $this->dispatcher = m::mock('Illuminate\Events\Dispatcher');
23 | $this->dispatcher->shouldReceive('dispatch');
24 | }
25 |
26 | protected function _after()
27 | {
28 | }
29 |
30 | /**
31 | * @test
32 | */
33 | public function initialisation()
34 | {
35 | $tester = new PermissionGateway($this->config, $this->repository, $this->dispatcher);
36 | $this->assertInstanceOf(PermissionGateway::class, $tester);
37 | }
38 |
39 | /**
40 | * @test
41 | */
42 | public function create()
43 | {
44 | $data = $this->getData();
45 |
46 | $request = m::mock('Illuminate\Http\Request');
47 | $request->shouldReceive('all')
48 | ->andReturn($data);
49 | $request->shouldReceive('get')
50 | ->with('roles', [])
51 | ->andReturn($data['roles']);
52 |
53 | $this->repository->shouldReceive('create->roles->sync')
54 | ->once();
55 | $this->dispatcher->shouldReceive('fire')
56 | ->with(m::any());
57 | $event = m::mock("overload:Acoustep\EntrustGui\Events\PermissionCreatedEvent");
58 | $event->shouldReceive('setModel');
59 |
60 | $tester = new PermissionGateway($this->config, $this->repository, $this->dispatcher);
61 | $result = $tester->create($request);
62 | $this->assertInternalType('object', $result);
63 | }
64 |
65 | /**
66 | * @test
67 | */
68 | public function find()
69 | {
70 | $id = 1;
71 | $repository = $this->repository;
72 | $repository->shouldReceive('with->find');
73 | $tester = new PermissionGateway($this->config, $this->repository, $this->dispatcher);
74 | $result = $tester->find($id);
75 | }
76 |
77 | /**
78 | * @test
79 | */
80 | public function update()
81 | {
82 | $data = $this->getData();
83 | $id = 1;
84 |
85 | $request = m::mock('Illuminate\Http\Request');
86 | $request->shouldReceive('all')
87 | ->andReturn($data);
88 |
89 | $this->repository->shouldReceive('update')->andReturn($data);
90 |
91 | $this->dispatcher->shouldReceive('fire')
92 | ->with(m::any());
93 | $event = m::mock("overload:Acoustep\EntrustGui\Events\PermissionUpdatedEvent");
94 | $event->shouldReceive('setModel');
95 |
96 | $tester = new PermissionGateway($this->config, $this->repository, $this->dispatcher);
97 | $result = $tester->update($request, $id);
98 | }
99 |
100 | /**
101 | * @test
102 | */
103 | public function delete()
104 | {
105 | $id = 1;
106 | $data = $this->getData();
107 |
108 | $this->repository->shouldReceive('find')->andReturn($data);
109 | $this->repository->shouldReceive('delete')->with($id);
110 |
111 | $this->dispatcher->shouldReceive('fire')
112 | ->with(m::any());
113 | $event = m::mock("overload:Acoustep\EntrustGui\Events\PermissionDeletedEvent");
114 | $event->shouldReceive('setModel');
115 |
116 | $tester = new PermissionGateway($this->config, $this->repository, $this->dispatcher);
117 | $result = $tester->delete($id);
118 |
119 |
120 | }
121 |
122 | protected function getData($override = [])
123 | {
124 | $data = [
125 | 'name' => 'create-user',
126 | 'display_name' => 'Create User',
127 | 'description' => 'Ability to create a user',
128 | 'roles' => [1,2,3],
129 | ];
130 |
131 | return array_merge($data, $override);
132 | }
133 |
134 | }
135 |
--------------------------------------------------------------------------------
/tests/unit/Gateways/RoleGatewayTest.php:
--------------------------------------------------------------------------------
1 | config = m::mock('Illuminate\Config\Repository');
21 | $this->repository = m::mock('Acoustep\EntrustGui\Repositories\RoleRepository, Prettus\Repository\Eloquent\BaseRepository');
22 | $this->dispatcher = m::mock('Illuminate\Events\Dispatcher');
23 | $this->dispatcher->shouldReceive('dispatch');
24 | }
25 |
26 | protected function _after()
27 | {
28 | }
29 |
30 | /**
31 | * @test
32 | */
33 | public function initialisation()
34 | {
35 | $tester = new RoleGateway($this->config, $this->repository, $this->dispatcher);
36 | $this->assertInstanceOf(RoleGateway::class, $tester);
37 | }
38 |
39 | /**
40 | * @test
41 | */
42 | public function create()
43 | {
44 | $data = $this->getData();
45 |
46 | $request = m::mock('Illuminate\Http\Request');
47 | $request->shouldReceive('all')
48 | ->andReturn($data);
49 | $request->shouldReceive('get')
50 | ->with('permissions', [])
51 | ->andReturn($data['permissions']);
52 |
53 | $this->repository->shouldReceive('create->perms->sync')
54 | ->once();
55 | $this->dispatcher->shouldReceive('fire')
56 | ->with(m::any());
57 | // $this->event_created_class->shouldReceive('setModel')
58 | // ->with(m::any());
59 | $event = m::mock("overload:Acoustep\EntrustGui\Events\RoleCreatedEvent");
60 | $event->shouldReceive('setModel');
61 |
62 | $tester = new RoleGateway($this->config, $this->repository, $this->dispatcher);
63 | $result = $tester->create($request);
64 | $this->assertInternalType('object', $result);
65 | }
66 |
67 | /**
68 | * @test
69 | */
70 | public function find()
71 | {
72 | $id = 1;
73 | $repository = $this->repository;
74 | $repository->shouldReceive('with->find');
75 | $tester = new RoleGateway($this->config, $this->repository, $this->dispatcher);
76 | $result = $tester->find($id);
77 | }
78 |
79 | /**
80 | * @test
81 | */
82 | public function update()
83 | {
84 | $data = $this->getData();
85 | $id = 1;
86 |
87 | $request = m::mock('Illuminate\Http\Request');
88 | $request->shouldReceive('all')
89 | ->andReturn($data);
90 |
91 | $this->repository->shouldReceive('update')->andReturn($data);
92 |
93 | $this->dispatcher->shouldReceive('fire')
94 | ->with(m::any());
95 | $event = m::mock("overload:Acoustep\EntrustGui\Events\RoleUpdatedEvent");
96 | $event->shouldReceive('setModel');
97 |
98 | $tester = new RoleGateway($this->config, $this->repository, $this->dispatcher);
99 | $result = $tester->update($request, $id);
100 | }
101 |
102 | /**
103 | * @test
104 | */
105 | public function delete()
106 | {
107 | $id = 1;
108 | $data = $this->getData();
109 |
110 | $this->repository->shouldReceive('find')->andReturn($data);
111 | $this->repository->shouldReceive('delete')->with($id);
112 |
113 | $this->dispatcher->shouldReceive('fire')
114 | ->with(m::any());
115 | $event = m::mock("overload:Acoustep\EntrustGui\Events\RoleDeletedEvent");
116 | $event->shouldReceive('setModel');
117 |
118 | $tester = new RoleGateway($this->config, $this->repository, $this->dispatcher);
119 | $result = $tester->delete($id);
120 |
121 | }
122 |
123 | protected function getData($override = [])
124 | {
125 | $data = [
126 | 'name' => 'Admin',
127 | 'display_name' => 'Admin',
128 | 'description' => 'The Administrator',
129 | 'permissions' => [1,2,3],
130 | ];
131 |
132 | return array_merge($data, $override);
133 | }
134 |
135 | }
136 |
--------------------------------------------------------------------------------
/tests/unit/Gateways/UserGatewayTest.php:
--------------------------------------------------------------------------------
1 | config = m::mock('Illuminate\Config\Repository');
27 | $this->config->shouldReceive('get')->andReturn('\Gateways\RoleDummy');
28 | $this->repository = m::mock('Acoustep\EntrustGui\Repositories\UserRepository, Prettus\Repository\Eloquent\BaseRepository');
29 | $this->dispatcher = m::mock('Illuminate\Events\Dispatcher');
30 | $this->dispatcher->shouldReceive('dispatch');
31 | $this->hash = m::mock('Illuminate\Contracts\Hashing\Hasher');
32 | }
33 |
34 | protected function _after()
35 | {
36 | }
37 |
38 | /**
39 | * @test
40 | */
41 | public function initialisation()
42 | {
43 | $tester = new UserGateway($this->config, $this->repository, $this->dispatcher, $this->hash);
44 | $this->assertInstanceOf(UserGateway::class, $tester);
45 | }
46 |
47 | /**
48 | * @test
49 | */
50 | public function create()
51 | {
52 | $data = $this->getData();
53 | $request = m::mock('Illuminate\Http\Request');
54 | $request->shouldReceive('all')
55 | ->andReturn($data);
56 | // $request->shouldReceive('get')
57 | // ->with('password', '')->andReturn($data['password']);
58 | $request->shouldReceive('get')
59 | ->with('roles', [])
60 | ->andReturn($data['roles']);
61 |
62 | $this->hash->shouldReceive('make');
63 |
64 | $this->repository->shouldReceive('create');
65 |
66 | $this->dispatcher->shouldReceive('fire')
67 | ->with(m::any());
68 | $event = m::mock("overload:Acoustep\EntrustGui\Events\UserCreatedEvent");
69 | $event->shouldReceive('setModel');
70 |
71 | $tester = new UserGateway($this->config, $this->repository, $this->dispatcher, $this->hash);
72 | $tester->create($request);
73 | }
74 |
75 | /**
76 | * @test
77 | */
78 | public function update()
79 | {
80 | $data = $this->getData();
81 | $id = 1;
82 | $request = m::mock('Illuminate\Http\Request');
83 | $request->shouldReceive('except')
84 | ->andReturn($data);
85 | $request->shouldReceive('has')
86 | ->with('password')->andReturn(true);
87 | $request->shouldReceive('get')
88 | ->with('password', false)->andReturn($data['password']);
89 | $request->shouldReceive('get')
90 | ->with('password')->andReturn($data['password']);
91 | $request->shouldReceive('get')
92 | ->with('password_confirmation')->andReturn($data['password']);
93 | $request->shouldReceive('get')
94 | ->with('roles', [])
95 | ->andReturn($data['roles']);
96 |
97 | $this->hash->shouldReceive('make');
98 |
99 | $this->repository->shouldReceive('update');
100 |
101 | $this->dispatcher->shouldReceive('fire')
102 | ->with(m::any());
103 | $event = m::mock("overload:Acoustep\EntrustGui\Events\UserUpdatedEvent");
104 | $event->shouldReceive('setModel');
105 |
106 | $tester = new UserGateway($this->config, $this->repository, $this->dispatcher, $this->hash);
107 | $tester->update($request, $id);
108 | }
109 |
110 |
111 | /**
112 | * @test
113 | */
114 | /**
115 | * @test
116 | */
117 | public function delete()
118 | {
119 | $id = 1;
120 | $data = $this->getData();
121 |
122 | $this->repository->shouldReceive('find')->andReturn($data);
123 | $this->repository->shouldReceive('delete')->with($id);
124 |
125 | $this->dispatcher->shouldReceive('fire')
126 | ->with(m::any());
127 | $event = m::mock("overload:Acoustep\EntrustGui\Events\UserDeletedEvent");
128 | $event->shouldReceive('setModel');
129 |
130 | $tester = new UserGateway($this->config, $this->repository, $this->dispatcher, $this->hash);
131 | $result = $tester->delete($id);
132 |
133 | }
134 |
135 |
136 | /**
137 | * @test
138 | */
139 | public function find()
140 | {
141 | $id = 1;
142 | $repository = $this->repository;
143 | $repository->shouldReceive('with->find');
144 | $tester = new UserGateway($this->config, $this->repository, $this->dispatcher, $this->hash);
145 | $result = $tester->find($id);
146 | }
147 |
148 |
149 |
150 |
151 |
152 | protected function getData($override = [])
153 | {
154 | $data = [
155 | 'id' => null,
156 | 'email' => 'email@email.com',
157 | 'password' => 'hunter2',
158 | 'roles' => [1,2,3],
159 | ];
160 |
161 | return array_merge($data, $override);
162 | }
163 |
164 | }
165 |
--------------------------------------------------------------------------------
/tests/unit/Http/Middleware/AdminAuthTest.php:
--------------------------------------------------------------------------------
1 | guard = m::mock('Illuminate\Contracts\Auth\Guard');
12 | $this->request = m::mock('Illuminate\Http\Request');
13 | $this->config = m::mock('Illuminate\Config\Repository');
14 | $this->response = m::mock('Illuminate\Http\Response');
15 | $this->redirect = m::mock('Illuminate\Routing\Redirector');
16 | }
17 |
18 | protected function _after()
19 | {
20 | }
21 |
22 | /**
23 | * @test
24 | */
25 | public function admin_can_access()
26 | {
27 | $this->guard->shouldReceive('guest')->andReturn(false);
28 | $this->request->shouldReceive('user->hasRole')->andReturn(true);
29 | $this->config->shouldReceive('get')->andReturn('admin');
30 | $next = function($request) {
31 | return true;
32 | };
33 | $tester = new AdminAuth($this->guard, $this->config, $this->response, $this->redirect);
34 | $result = $tester->handle($this->request, $next);
35 | $this->assertTrue($result);
36 | }
37 |
38 | /**
39 | * @test
40 | */
41 | public function moderator_cant_access()
42 | {
43 | $this->guard->shouldReceive('guest')->andReturn(false);
44 | $this->request->shouldReceive('user->hasRole')->andReturn(false);
45 | $this->config->shouldReceive('get')->andReturn('admin');
46 | $this->response->shouldReceive('make')->with('Unauthorized.', 401);
47 | $next = function($request) {
48 | return true;
49 | };
50 | $tester = new AdminAuth($this->guard, $this->config, $this->response, $this->redirect);
51 | $result = $tester->handle($this->request, $next);
52 | $this->assertNotTrue($result);
53 | }
54 |
55 | /**
56 | * @test
57 | */
58 | public function guest_cant_access_with_ajax()
59 | {
60 | $this->guard->shouldReceive('guest')->andReturn(true);
61 | $this->request->shouldReceive('ajax')->andReturn(true);
62 | $this->response->shouldReceive('make')->with('Unauthorized.', 401);
63 | $next = function($request) {
64 | return true;
65 | };
66 | $tester = new AdminAuth($this->guard, $this->config, $this->response, $this->redirect);
67 | $result = $tester->handle($this->request, $next);
68 | $this->assertNotTrue($result);
69 | }
70 |
71 | /**
72 | * @test
73 | */
74 | public function guest_cant_access()
75 | {
76 | $this->guard->shouldReceive('guest')->andReturn(true);
77 | $this->request->shouldReceive('ajax')->andReturn(false);
78 | $this->redirect->shouldReceive('guest')->with('auth/login');
79 | $next = function($request) {
80 | return true;
81 | };
82 | $tester = new AdminAuth($this->guard, $this->config, $this->response, $this->redirect);
83 | $result = $tester->handle($this->request, $next);
84 | $this->assertNotTrue($result);
85 | }
86 |
87 | }
88 |
--------------------------------------------------------------------------------
/tests/unit/Http/RoutesTest.php:
--------------------------------------------------------------------------------
1 |
11 | *
12 | * @todo: Find a way to test the route Classes with testbench (Find another tool if it's impossible).
13 | */
14 | class RoutesTest extends TestCase
15 | {
16 |
17 | public function setUp()
18 | {
19 | parent::setUp();
20 | $this->artisan('migrate', [
21 | '--database' => 'testbench',
22 | '--realpath' => __DIR__.'/../../../database/migrations',
23 | ]);
24 | }
25 | /* ------------------------------------------------------------------------------------------------
26 | | Test Functions
27 | | ------------------------------------------------------------------------------------------------
28 | */
29 |
30 | /**
31 | * @test
32 | * */
33 | public function it_can_see_users_index_page()
34 | {
35 | $response = $this->route('GET', 'entrust-gui::users.index');
36 |
37 | $this->assertResponseOk();
38 | $this->assertContains(
39 | 'Users
',
40 | $response->getContent()
41 | );
42 | }
43 |
44 | /**
45 | * @test
46 | * */
47 | public function it_can_see_users_create_page()
48 | {
49 | $response = $this->route('GET', 'entrust-gui::users.create');
50 |
51 | $this->assertResponseOk();
52 | $this->assertContains(
53 | 'Create User
',
54 | $response->getContent()
55 | );
56 | }
57 |
58 | /**
59 | * @test
60 | * */
61 | public function it_can_see_role_index_page()
62 | {
63 | $response = $this->route('GET', 'entrust-gui::roles.index');
64 |
65 | $this->assertResponseOk();
66 | $this->assertContains(
67 | 'Roles
',
68 | $response->getContent()
69 | );
70 | }
71 |
72 | /**
73 | * @test
74 | * */
75 | public function it_can_see_role_create_page()
76 | {
77 | $response = $this->route('GET', 'entrust-gui::roles.create');
78 |
79 | $this->assertResponseOk();
80 | $this->assertContains(
81 | 'Create Role
',
82 | $response->getContent()
83 | );
84 | }
85 |
86 | /**
87 | * @test
88 | * */
89 | public function it_can_see_permission_index_page()
90 | {
91 | $response = $this->route('GET', 'entrust-gui::permissions.index');
92 |
93 | $this->assertResponseOk();
94 | $this->assertContains(
95 | 'Permissions
',
96 | $response->getContent()
97 | );
98 | }
99 |
100 | /**
101 | * @test
102 | * */
103 | public function it_can_see_permission_create_page()
104 | {
105 | $response = $this->route('GET', 'entrust-gui::permissions.create');
106 |
107 | $this->assertResponseOk();
108 | $this->assertContains(
109 | 'Create Permission
',
110 | $response->getContent()
111 | );
112 | }
113 |
114 | }
115 |
--------------------------------------------------------------------------------
/tests/unit/_bootstrap.php:
--------------------------------------------------------------------------------
1 | 'Create',
3 | 'cancel' => 'Cancel',
4 | 'save' => 'Save',
5 | 'edit' => 'Edit',
6 | 'delete' => 'Delete',
7 | 'create-user' => 'Create User',
8 | 'create-permission' => 'Create Permission',
9 | 'create-role' => 'Create Role',
10 | ];
11 |
--------------------------------------------------------------------------------
/translations/en/flash.php:
--------------------------------------------------------------------------------
1 | 'Success:',
3 | 'error' => 'Error:',
4 | 'warning' => 'Warning:',
5 | 'info' => 'FYI:',
6 | ];
7 |
--------------------------------------------------------------------------------
/translations/en/navigation.php:
--------------------------------------------------------------------------------
1 | 'Users',
3 | 'roles' => 'Roles',
4 | 'permissions' => 'Permissions',
5 | ];
6 |
--------------------------------------------------------------------------------
/translations/en/permissions.php:
--------------------------------------------------------------------------------
1 | 'You have successfully created a new permission.',
3 | 'destroyed' => 'You have successfully removed a permission.',
4 | 'updated' => 'You have successfully updated a permission.',
5 | ];
6 |
--------------------------------------------------------------------------------
/translations/en/roles.php:
--------------------------------------------------------------------------------
1 | 'You have successfully created a new role.',
3 | 'destroyed' => 'You have successfully removed a role.',
4 | 'updated' => 'You have successfully updated a role.',
5 | ];
6 |
--------------------------------------------------------------------------------
/translations/en/users.php:
--------------------------------------------------------------------------------
1 | 'You have successfully created a new user.',
3 | 'destroyed' => 'You have successfully removed a user.',
4 | 'updated' => 'You have successfully updated a user.',
5 | ];
6 |
--------------------------------------------------------------------------------
/translations/es/button.php:
--------------------------------------------------------------------------------
1 | 'Crear',
3 | 'cancel' => 'Cancelar',
4 | 'save' => 'Guardar',
5 | 'edit' => 'Editar',
6 | 'delete' => 'Borrar',
7 | 'create-user' => 'Crear Usuario',
8 | 'create-permission' => 'Crear Permiso',
9 | 'create-role' => 'Crear Rol',
10 | ];
11 |
--------------------------------------------------------------------------------
/translations/es/flash.php:
--------------------------------------------------------------------------------
1 | 'Éxito:',
3 | 'error' => 'Error:',
4 | 'warning' => 'Advertencia:',
5 | 'info' => 'Información:',
6 | ];
7 |
--------------------------------------------------------------------------------
/translations/es/navigation.php:
--------------------------------------------------------------------------------
1 | 'Usuarios',
3 | 'roles' => 'Roles',
4 | 'permissions' => 'Permisos',
5 | ];
6 |
--------------------------------------------------------------------------------
/translations/es/permissions.php:
--------------------------------------------------------------------------------
1 | 'Permiso creado correctamente.',
3 | 'destroyed' => 'Permiso eliminado correctamente.',
4 | 'updated' => 'Permiso actualizado correctamente.',
5 | ];
6 |
--------------------------------------------------------------------------------
/translations/es/roles.php:
--------------------------------------------------------------------------------
1 | 'Rol creado correctamente.',
3 | 'destroyed' => 'Rol eliminado correctamente.',
4 | 'updated' => 'Rol actualizado correctamente.',
5 | ];
6 |
--------------------------------------------------------------------------------
/translations/es/users.php:
--------------------------------------------------------------------------------
1 | 'Usuario creado correctamente.',
3 | 'destroyed' => 'Usuario eliminado correctamente.',
4 | 'updated' => 'Usuario actualizado correctamente.',
5 | ];
6 |
--------------------------------------------------------------------------------
/translations/pt-BR/button.php:
--------------------------------------------------------------------------------
1 | 'Cadastrar',
3 | 'cancel' => 'Cancelar',
4 | 'save' => 'Salvar',
5 | 'edit' => 'Editar',
6 | 'delete' => 'Deletar',
7 | 'create-user' => 'Cadastrar Usuário',
8 | 'create-permission' => 'Cadastrar Permissão',
9 | 'create-role' => 'Cadastrar Papel',
10 | ];
11 |
--------------------------------------------------------------------------------
/translations/pt-BR/flash.php:
--------------------------------------------------------------------------------
1 | 'Sucesso:',
3 | 'error' => 'Erro:',
4 | 'warning' => 'Aviso:',
5 | 'info' => 'Info:',
6 | ];
7 |
--------------------------------------------------------------------------------
/translations/pt-BR/navigation.php:
--------------------------------------------------------------------------------
1 | 'Usuários',
3 | 'roles' => 'Papéis',
4 | 'permissions' => 'Permissões',
5 | ];
6 |
--------------------------------------------------------------------------------
/translations/pt-BR/permissions.php:
--------------------------------------------------------------------------------
1 | 'Permissão cadastrada.',
3 | 'destroyed' => 'Permissão removida.',
4 | 'updated' => 'Permissão atualizada.',
5 | ];
6 |
--------------------------------------------------------------------------------
/translations/pt-BR/roles.php:
--------------------------------------------------------------------------------
1 | 'Papel cadastrado.',
3 | 'destroyed' => 'Papel deletado.',
4 | 'updated' => 'Papel atualizado.',
5 | ];
6 |
--------------------------------------------------------------------------------
/translations/pt-BR/users.php:
--------------------------------------------------------------------------------
1 | 'Usuário cadastrado.',
3 | 'destroyed' => 'Usuário deletado.',
4 | 'updated' => 'Usuário atualizado.',
5 | ];
6 |
--------------------------------------------------------------------------------
/views/app.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | title
5 |
6 |
7 |
8 |
9 |
20 |
21 |
22 | @include('entrust-gui::partials.navigation')
23 |
24 |
25 |
26 |
@yield('heading')
27 | @include('entrust-gui::partials.notifications')
28 | @yield('content')
29 |
30 |
31 |
32 |
33 |
34 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/views/partials/navigation.blade.php:
--------------------------------------------------------------------------------
1 |
24 |
--------------------------------------------------------------------------------
/views/partials/notifications.blade.php:
--------------------------------------------------------------------------------
1 | @if (isset($errors) && count($errors->all()) > 0)
2 |
3 |
4 |
5 |
6 |
Error
7 | The following error has occured:
8 |
9 | {!! implode('', $errors->all('- :message
')) !!}
10 |
11 |
12 |
13 |
14 | @endif
15 | @if ($message = Session::get('success'))
16 |
17 |
18 |
19 |
20 | {{ trans('entrust-gui::flash.success') }} {{ $message }}
21 |
22 | {{ Session::forget('success') }}
23 |
24 |
25 | @endif
26 |
27 | @if ($message = Session::get('error'))
28 |
29 |
30 |
31 |
32 | {{ trans('entrust-gui::flash.error') }} {{ $message }}
33 |
34 | {{ Session::forget('error') }}
35 |
36 |
37 | @endif
38 |
39 | @if ($message = Session::get('warning'))
40 |
41 |
42 |
43 |
44 | {{ trans('entrust-gui::flash.warning') }} {{ $message }}
45 |
46 | {{ Session::forget('warning') }}
47 |
48 |
49 | @endif
50 |
51 | @if ($message = Session::get('info'))
52 |
53 |
54 |
55 |
56 | {{ trans('entrust-gui::flash.info') }} {{ $message }}
57 |
58 | {{ Session::forget('info') }}
59 |
60 |
61 | @endif
62 |
--------------------------------------------------------------------------------
/views/permissions/create.blade.php:
--------------------------------------------------------------------------------
1 | @extends(Config::get('entrust-gui.layout'))
2 |
3 | @section('heading', 'Create Permission')
4 |
5 | @section('content')
6 |
11 | @endsection
12 |
--------------------------------------------------------------------------------
/views/permissions/edit.blade.php:
--------------------------------------------------------------------------------
1 | @extends(Config::get('entrust-gui.layout'))
2 |
3 | @section('heading', 'Edit Permission')
4 |
5 | @section('content')
6 |
12 | @endsection
13 |
--------------------------------------------------------------------------------
/views/permissions/index.blade.php:
--------------------------------------------------------------------------------
1 | @extends(Config::get('entrust-gui.layout'))
2 |
3 | @section('heading', 'Permissions')
4 |
5 | @section('content')
6 |
9 |
10 |
11 | Name |
12 | Actions |
13 |
14 | @foreach($models as $model)
15 |
16 | {{ $model->display_name }}
17 | |
18 |
24 | |
25 |
26 | @endforeach
27 |
28 |
29 | {!! $models->render() !!}
30 |
31 | @endsection
32 |
--------------------------------------------------------------------------------
/views/permissions/partials/form.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
21 |
22 |
--------------------------------------------------------------------------------
/views/roles/create.blade.php:
--------------------------------------------------------------------------------
1 | @extends(Config::get('entrust-gui.layout'))
2 |
3 | @section('heading', 'Create Role')
4 |
5 | @section('content')
6 |
11 | @endsection
12 |
--------------------------------------------------------------------------------
/views/roles/edit.blade.php:
--------------------------------------------------------------------------------
1 | @extends(Config::get('entrust-gui.layout'))
2 |
3 | @section('heading', 'Edit Role')
4 |
5 | @section('content')
6 |
12 | @endsection
13 |
--------------------------------------------------------------------------------
/views/roles/index.blade.php:
--------------------------------------------------------------------------------
1 | @extends(Config::get('entrust-gui.layout'))
2 |
3 | @section('heading', 'Roles')
4 |
5 | @section('content')
6 |
9 |
10 |
11 | Name |
12 | Actions |
13 |
14 | @foreach($models as $model)
15 |
16 | {{ $model->name }}
17 | |
18 |
24 | |
25 |
26 | @endforeach
27 |
28 |
29 | {!! $models->render() !!}
30 |
31 | @endsection
32 |
--------------------------------------------------------------------------------
/views/roles/partials/form.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
21 |
22 |
--------------------------------------------------------------------------------
/views/users/create.blade.php:
--------------------------------------------------------------------------------
1 | @extends(Config::get('entrust-gui.layout'))
2 |
3 | @section('heading', 'Create User')
4 |
5 | @section('content')
6 |
11 | @endsection
12 |
--------------------------------------------------------------------------------
/views/users/edit.blade.php:
--------------------------------------------------------------------------------
1 | @extends(Config::get('entrust-gui.layout'))
2 |
3 | @section('heading', 'Edit User')
4 |
5 | @section('content')
6 |
12 | @endsection
13 |
14 |
--------------------------------------------------------------------------------
/views/users/index.blade.php:
--------------------------------------------------------------------------------
1 | @extends(Config::get('entrust-gui.layout'))
2 |
3 | @section('heading', 'Users')
4 |
5 | @section('content')
6 |
9 |
10 |
11 | Email |
12 | Actions |
13 |
14 | @foreach($users as $user)
15 |
16 |
17 | {{ $user->email }}
18 | |
19 |
27 | |
28 |
29 | @endforeach
30 |
31 |
32 | {!! $users->render() !!}
33 |
34 | @endsection
35 |
--------------------------------------------------------------------------------
/views/users/partials/form.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
19 | @if(Config::get('entrust-gui.confirmable') === true)
20 |
21 |
22 |
23 |
24 | @endif
25 |
26 |
27 |
32 |
33 |
--------------------------------------------------------------------------------