permission.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. return [
  3. 'models' => [
  4. /*
  5. * When using the "HasPermissions" trait from this package, we need to know which
  6. * Eloquent model should be used to retrieve your permissions. Of course, it
  7. * is often just the "Permission" model but you may use whatever you like.
  8. *
  9. * The model you want to use as a Permission model needs to implement the
  10. * `Spatie\Permission\Contracts\Permission` contract.
  11. */
  12. 'permission' => Spatie\Permission\Models\Permission::class,
  13. /*
  14. * When using the "HasRoles" trait from this package, we need to know which
  15. * Eloquent model should be used to retrieve your roles. Of course, it
  16. * is often just the "Role" model but you may use whatever you like.
  17. *
  18. * The model you want to use as a Role model needs to implement the
  19. * `Spatie\Permission\Contracts\Role` contract.
  20. */
  21. 'role' => Spatie\Permission\Models\Role::class,
  22. ],
  23. 'table_names' => [
  24. /*
  25. * When using the "HasRoles" trait from this package, we need to know which
  26. * table should be used to retrieve your roles. We have chosen a basic
  27. * default value but you may easily change it to any table you like.
  28. */
  29. 'roles' => 'roles',
  30. /*
  31. * When using the "HasPermissions" trait from this package, we need to know which
  32. * table should be used to retrieve your permissions. We have chosen a basic
  33. * default value but you may easily change it to any table you like.
  34. */
  35. 'permissions' => 'permissions',
  36. /*
  37. * When using the "HasPermissions" trait from this package, we need to know which
  38. * table should be used to retrieve your models permissions. We have chosen a
  39. * basic default value but you may easily change it to any table you like.
  40. */
  41. 'model_has_permissions' => 'model_has_permissions',
  42. /*
  43. * When using the "HasRoles" trait from this package, we need to know which
  44. * table should be used to retrieve your models roles. We have chosen a
  45. * basic default value but you may easily change it to any table you like.
  46. */
  47. 'model_has_roles' => 'model_has_roles',
  48. /*
  49. * When using the "HasRoles" trait from this package, we need to know which
  50. * table should be used to retrieve your roles permissions. We have chosen a
  51. * basic default value but you may easily change it to any table you like.
  52. */
  53. 'role_has_permissions' => 'role_has_permissions',
  54. ],
  55. 'column_names' => [
  56. /*
  57. * Change this if you want to name the related model primary key other than
  58. * `model_id`.
  59. *
  60. * For example, this would be nice if your primary keys are all UUIDs. In
  61. * that case, name this `model_uuid`.
  62. */
  63. 'model_morph_key' => 'model_id',
  64. ],
  65. /*
  66. * When set to true, the required permission/role names are added to the exception
  67. * message. This could be considered an information leak in some contexts, so
  68. * the default setting is false here for optimum safety.
  69. */
  70. 'display_permission_in_exception' => false,
  71. 'cache' => [
  72. /*
  73. * By default all permissions are cached for 24 hours to speed up performance.
  74. * When permissions or roles are updated the cache is flushed automatically.
  75. */
  76. 'expiration_time' => \DateInterval::createFromDateString('24 hours'),
  77. /*
  78. * The cache key used to store all permissions.
  79. */
  80. 'key' => 'spatie.permission.cache',
  81. /*
  82. * When checking for a permission against a model by passing a Permission
  83. * instance to the check, this key determines what attribute on the
  84. * Permissions model is used to cache against.
  85. *
  86. * Ideally, this should match your preferred way of checking permissions, eg:
  87. * `$user->can('view-posts')` would be 'name'.
  88. */
  89. 'model_key' => 'name',
  90. /*
  91. * You may optionally indicate a specific cache driver to use for permission and
  92. * role caching using any of the `store` drivers listed in the cache.php config
  93. * file. Using 'default' here means to use the `default` set in cache.php.
  94. */
  95. 'store' => 'default',
  96. ],
  97. ];