Skip to content

Commit

Permalink
Add support for silber/bouncer v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yakidahan committed Feb 23, 2022
1 parent fec0fae commit edf2810
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 29 deletions.
8 changes: 0 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
/.idea
/vendor
/node_modules
package-lock.json
composer.phar
composer.lock
phpunit.xml
.phpunit.result.cache
.DS_Store
Thumbs.db
13 changes: 1 addition & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public function tools()
Next, add the Roles and Abilities `MorphToMany` fields to your User resource in `app/Nova/User.php` file:

```php
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\MorphToMany;
use Laravel\Nova\Fields\Text;

public function fields(Request $request)
{
Expand Down Expand Up @@ -115,17 +115,6 @@ You may generate a policy using the `make:policy` artisan command:

php artisan make:policy UserPolicy --model=User

### Registering Policies

Once the policy exists, it needs to be registered in `app/Providers/AuthServiceProvider.php` file:

```php
protected $policies = [
// ...
'App\User' => 'App\Policies\UserPolicy',
];
```

## Contributing

Thank you for considering contributing to the Nova Bouncer.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"require": {
"php": "^7.2|^8.0",
"laravel/nova": "*",
"silber/bouncer": "v1.0.0-rc.4|v1.0.0-rc.5|v1.0.0-rc.6|v1.0.0-rc.7|v1.0.0-rc.8|v1.0.0-rc.9|v1.0.0-rc.10|v1.0.0-rc.11|v1.0.0-rc.12|v1.0.0-rc.13"
"silber/bouncer": "^1.0"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion config/bouncer-tool.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

'entities' => [
'*' => 'Everything',
'App\User' => 'User',
'App\Models\User' => 'User',
'Silber\Bouncer\Database\Role' => 'Role',
'Silber\Bouncer\Database\Ability' => 'Ability',
],
Expand Down
16 changes: 15 additions & 1 deletion resources/views/navigation.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
@if (Auth::user()->can('viewAny', \Silber\Bouncer\Database\Role::class) || Auth::user()->can('viewAny', \Silber\Bouncer\Database\Ability::class))
<h3 class="flex items-center font-normal text-white mb-6 text-base no-underline">
<svg class="sidebar-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path fill="#B3C1D1" d="M 18.300781 3.351562 C 18.296875 3.085938 18.105469 2.859375 17.839844 2.820312 C 16.605469 2.652344 15.386719 2.355469 14.191406 1.917969 C 13.003906 1.484375 11.6875 0.875 10.269531 0.078125 C 10.089844 -0.0234375 9.921875 -0.0273438 9.742188 0.078125 C 8.332031 0.875 7.027344 1.484375 5.828125 1.917969 C 4.632812 2.355469 3.417969 2.652344 2.191406 2.820312 C 1.925781 2.859375 1.738281 3.085938 1.710938 3.351562 C 1.59375 8.382812 2.695312 12.496094 5.003906 15.695312 C 6.265625 17.441406 7.839844 18.855469 9.742188 19.933594 C 9.886719 20.042969 10.117188 20.03125 10.289062 19.933594 C 12.179688 18.835938 13.75 17.433594 15.007812 15.695312 C 17.320312 12.5 18.414062 8.382812 18.300781 3.351562 Z M 14.125 15.078125 C 13.03125 16.585938 11.664062 17.84375 10.007812 18.855469 C 8.347656 17.84375 6.972656 16.59375 5.886719 15.078125 C 3.785156 12.148438 2.757812 8.402344 2.796875 3.832031 C 3.957031 3.644531 5.101562 3.332031 6.25 2.910156 C 7.398438 2.488281 8.652344 1.910156 10.007812 1.175781 C 11.359375 1.910156 12.605469 2.488281 13.75 2.910156 C 14.898438 3.332031 16.054688 3.644531 17.214844 3.832031 C 17.253906 8.429688 16.21875 12.183594 14.125 15.078125 Z M 14.125 15.078125"/></svg></svg>
<svg class="sidebar-icon" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 459 459">
<g>
<path fill="#231F20" d="M189.154,92.979c4.329,4.915,20.94,13.737,28,10.666c6.588-2.866,8.427-13.824,12.607-15.048 c0.218-0.064,0.453-0.064,0.671,0c4.18,1.224,6.019,12.183,12.607,15.048c7.06,3.071,23.671-5.751,28-10.666 c3.132-3.556,5.387-13.739,6.422-19.276c0.385-2.057-0.698-4.022-2.399-4.329c-19.801-3.568-42.966,9.356-42.966,9.356 l-0.002,0.001c-1.253,0.78-2.742,0.78-3.995,0l-0.001-0.001c0,0-23.166-12.924-42.966-9.356c-1.701,0.307-2.784,2.272-2.399,4.329 C183.767,79.239,186.021,89.422,189.154,92.979z"/>
<path fill="#231F20" d="M253.447,132.273c-4.196-7.038-10.704-15.022-23.207-15.037c-0.049,0-0.096,0.003-0.144,0.006 c-0.048-0.003-0.096-0.006-0.144,0.01c-12.944,0-19.085,7.966-23.207,14.998c-0.658,1.124-2.191,1.321-3.116,0.404 c-9.032-8.952-17.454-17.662-19.505-16.182c10.676,16.235,22.965,45.739,45.9,45.498c0.045,0,0.089-0.001,0.134-0.002 c22.961-0.352,35.176-29.175,45.908-45.496c-2.051-1.48-10.478,7.236-19.514,16.191 C255.633,133.576,254.11,133.386,253.447,132.273z M230.007,126.444v0.009c0.03-0.001,0.06-0.004,0.089-0.006 c0.029,0.003,0.059,0.005,0.089,0.006v-0.009c6.276,0.104,11.423,4.115,13.596,9.645c-3.57-1.812-8.379-2.93-13.685-2.93 c-5.306,0-10.115,1.119-13.685,2.93C218.584,130.558,223.731,126.548,230.007,126.444z"/>
<g>
<path fill="#231F20" d="M349.186,170.74c-15.151-9.963-33.49-14.815-51.101-18.954c-4.949-1.164-10.279-2.867-12.211-6.664 l-3.48-6.837l-2.931,7.552c-8.754,22.563-28.727,46.325-50.017,46.325c-21.243,0-41.197-23.718-49.975-46.21l-2.889-7.405 l-3.495,6.656c-1.967,3.742-7.261,5.428-12.169,6.583c-17.613,4.138-35.952,8.991-51.103,18.954 c-27.489,18.079-41.343,51.828-36.403,84.539l0.667,4.415l4.004-1.326c18.08-5.993,40.041-4.675,59.778,3.557 c10.429,4.351,18.447,9.987,23.846,16.707c5.383,6.698,7.941,14.729,7.088,21.581c-19.155-4.001-26.267,2.155-26.267,2.155 c8.733-1.044,33.634,4.165,44.614,8.708c6.819,2.821,13.422,6.41,19.754,9.852c2.633,1.431,5.345,2.906,8.043,4.31 c14.081,7.327,28.683,13.217,43.611,17.664c-15.713,6.944-31.658,13.531-48.194,17.389c-14.082,3.287-28.707,4.598-43.576,3.92 c-4.737-0.217-9.302-0.881-14.145-1.584c-2.146-0.312-4.296-0.624-6.461-0.896c-2.196-0.276-6.572-2.732-8.252-0.491 c-3.089,4.121,9.794,19.95,12.267,23.986c1.874,3.059,5.594,5.023,9.488,5.023h139.648c3.894,0,7.614-1.964,9.488-5.023 c4.812-7.853,9.624-15.706,14.436-23.559c7.552-12.327,0.32-13.335-10.991-14.194c-7.989-0.606-15.948-1.6-23.839-2.979 c-15.271-2.67-30.293-6.783-44.773-12.324c-8.791-3.364-17.426-7.26-25.85-11.677c-2.658-1.393-5.354-2.87-7.972-4.303 c-6.503-3.562-13.284-7.276-20.454-10.264c-4.997-2.082-9.848-3.635-14.528-4.665c1.137-8.421-1.796-17.955-8.297-26.132 c-0.617-0.776-1-1.423-1.273-2.008l-2.684-3.168c5.179-2.739,16.145-2.959,19.457-2.952c7.003,0.015,12.618,3.4,18.008,7.513 c12.777,9.749,25.207,13.818,40.968,15.965c2.557,0.348,5.198,0.708,7.777,1.123c9.793,1.576,18.482,2.356,26.497,2.356 c5.71,0,11.091-0.396,16.29-1.185c1.21-0.184,2.424-0.372,3.641-0.561c12.465-1.932,25.414-3.941,36.998-1.258 c0,0-1.5-9.285-37.402-4.588c5.686-6.566,15.896-21.09,26.319-24.439c20.36-6.542,41.697-9.55,59.777-3.557l4.004,1.326 l0.667-4.415C390.529,222.568,376.675,188.819,349.186,170.74z"/>
</g>
<path fill="#DC5A56" d="M283.613,149.067c4.524,6.155,15.59,6.591,22.29,8.771c27.551,8.964,53.664,16.944,65.418,45.075 c5.299,12.683,12.007,51.265,8.286,49.993c-21.301-7.278-53.111-4.103-71.075,9.461c-4.55-18.434,0.263-43.49,10.769-59.306 c-9.384,7.846-19.076,10.154-21.846,74.306c-1.385,3.385-2.648,9.275-10.154,10.615c-14.233,2.541-39.817-2.052-52.153-3.231 c-20.923-2-28.968-14.33-36.614-18.153c-13.538-6.769-38.153-5.384-38.153-5.384s3.692-41.537-17.384-51.999 c9.157,13.712,14.153,34.768,7.077,51.383c-18.799-14.637-49.065-16.813-71.075-7.692c-7.36-17.786,10.012-55.178,12.923-59.383 c15.521-22.421,40.14-30.093,65.537-35.384c7.384-1.538,19.076-6.154,19.076-6.154s17.538,44.307,52.614,45.23 c14.618,0.385,22.29-4.423,32.922-14.461C272.704,172.715,280.378,160.6,283.613,149.067z"/>
<path opacity="0.09" fill="#414042" d="M258.994,281.483c-20.56-2.146-44.052-16.555-65.362-16.866 c1.711,0.559,3.362,1.21,4.902,1.98c7.646,3.823,15.692,16.153,36.614,18.153c12.335,1.179,37.919,5.771,52.153,3.231 c7.505-1.34,8.769-7.231,10.154-10.615c0.294-6.817,0.669-12.916,1.112-18.407C291.435,273.516,278.689,283.539,258.994,281.483z"/>
<path opacity="0.09" fill="#414042" d="M318.81,217.396c0.151-5.079,0.581-10.2,1.326-15.268c-0.693,0.587-1.355,1.205-1.977,1.862 c0.38-0.304,0.761-0.612,1.141-0.93c-10.506,15.816-15.319,40.872-10.769,59.306c4.023-3.038,8.765-5.525,13.903-7.52 C319.599,242.39,318.448,229.543,318.81,217.396z"/>
<path opacity="0.09" fill="#414042" d="M146.979,218.598c0.94,12.731-0.984,25.079-4.888,36.878 c2.827,1.497,5.509,3.194,7.983,5.121c6.054-14.215,3.258-31.667-3.406-45.003C146.784,216.592,146.904,217.589,146.979,218.598z"/>
<path fill="#DC5A56" d="M145.151,367.364l11.538,18l147.689-2.308l13.384-28.615c0,0-37.538-4.308-53.845-9.231 C263.917,345.211,201.457,380.287,145.151,367.364z"/>
<path opacity="0.09" fill="#414042" d="M237.927,362.604c14.779-6.027,27.157-13.038,43.503-10.251 c12.434,2.12,24.057,5.679,34.657,1.89c-7.455-0.898-37.918-4.73-52.17-9.032c0,0-47.753,26.815-97.391,24.914 C190.064,375.205,215.822,371.62,237.927,362.604z"/>
</g>
</svg>
<span class="sidebar-label">
{{ __('Bouncer') }}
</span>
Expand Down
Binary file modified screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions src/Nova/Ability.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ public function fields(Request $request)
return [
ID::make()->sortable(),

Text::make('Title')
->sortable()
->rules('required', 'max:255'),

Select::make('Name')
->sortable()
->options(config('bouncer-tool.actions'))
->displayUsingLabels(),

Text::make('Title')
->sortable()
->rules('required', 'max:255'),

Select::make('Entity Type')
->options(config('bouncer-tool.entities'))
->displayUsingLabels(),
Expand Down
4 changes: 2 additions & 2 deletions src/Nova/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ public function fields(Request $request)
return [
ID::make()->sortable(),

Text::make('Title')
Text::make('Name')
->sortable()
->rules('required', 'max:255'),

Text::make('Name')
Text::make('Title')
->sortable()
->rules('required', 'max:255'),

Expand Down

0 comments on commit edf2810

Please sign in to comment.