Framework: Gate::resource should merge extra habilites

Created on 15 Jul 2017  路  3Comments  路  Source: laravel/framework

  • Laravel Version: v5.4.28
  • PHP Version: 7.1.4-1+deb.sury.org~xenial+1
  • Database Driver & Version: Irrelevant

Description:

Using the method Gate::resource() and defining the last attribute array $abilities = null as described on the documentation:

By default, the view, create, update, and delete abilities will be defined. You may define additional abilities by passing an array as the third argument to the resource method. The key of the array defines the name of the ability while the value defines the method name:

Currently, if you define the third argument it is overriding the default abilities on the resource method.

Steps To Reproduce:

Use the method Gate::resource() passing the third attribute as an array of extra abilities.

All 3 comments

i agree with you, the wording on the documentation suggests that they will merge, but personally i would prefer to keep the existing functionality, and just change the docs.

by overriding, you still have the ability to define extra methods by something like

Gate::resource('blogs', 'BlogController', ['index', 'create', 'store', 'edit', 'update', 'destroy', 'foo', 'bar']);

granted, it is a little verbose, but if we switch to a merging functionality, we lose the ability to only define our custom methods, and get rid of the default ones.

Gate::resource('blogs', 'BlogController', ['foo', 'bar']);

@browner12 Sounds reasonable just update the docs with the correct information.

Thanks for https://github.com/wlepinski/docs/pull/1, please make sure you open an actual PR on the laravel/docs repo, you've opened a PR on your own repo :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shopblocks picture shopblocks  路  3Comments

digirew picture digirew  路  3Comments

gabriellimo picture gabriellimo  路  3Comments

SachinAgarwal1337 picture SachinAgarwal1337  路  3Comments

Fuzzyma picture Fuzzyma  路  3Comments