permission.php 5.0 KB

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