You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

147 lines
4.6 KiB

1 month ago
  1. <?php
  2. return [
  3. /**
  4. * What attributes do we use to build the slug?
  5. * This can be a single field, like "name" which will build a slug from:
  6. *
  7. * $model->name;
  8. *
  9. * Or it can be an array of fields, like ["name", "company"], which builds a slug from:
  10. *
  11. * $model->name . ' ' . $model->company;
  12. *
  13. * If you've defined custom getters in your model, you can use those too,
  14. * since Eloquent will call them when you request a custom attribute.
  15. *
  16. * Defaults to null, which uses the toString() method on your model.
  17. */
  18. 'source' => null,
  19. /**
  20. * The maximum length of a generated slug. Defaults to "null", which means
  21. * no length restrictions are enforced. Set it to a positive integer if you
  22. * want to make sure your slugs aren't too long.
  23. */
  24. 'maxLength' => null,
  25. /**
  26. * If you are setting a maximum length on your slugs, you may not want the
  27. * truncated string to split a word in half. The default setting of "true"
  28. * will ensure this, e.g. with a maxLength of 12:
  29. *
  30. * "my source string" -> "my-source"
  31. *
  32. * Setting it to "false" will simply truncate the generated slug at the
  33. * desired length, e.g.:
  34. *
  35. * "my source string" -> "my-source-st"
  36. */
  37. 'maxLengthKeepWords' => true,
  38. /**
  39. * If left to "null", then use the cocur/slugify package to generate the slug
  40. * (with the separator defined below).
  41. *
  42. * Set this to a closure that accepts two parameters (string and separator)
  43. * to define a custom slugger. e.g.:
  44. *
  45. * 'method' => function( $string, $sep ) {
  46. * return preg_replace('/[^a-z]+/i', $sep, $string);
  47. * },
  48. *
  49. * Otherwise, this will be treated as a callable to be used. e.g.:
  50. *
  51. * 'method' => array('Str','slug'),
  52. */
  53. 'method' => null,
  54. /**
  55. * Separator to use when generating slugs. Defaults to a hyphen.
  56. */
  57. 'separator' => '-',
  58. /**
  59. * Enforce uniqueness of slugs? Defaults to true.
  60. * If a generated slug already exists, an incremental numeric
  61. * value will be appended to the end until a unique slug is found. e.g.:
  62. *
  63. * my-slug
  64. * my-slug-1
  65. * my-slug-2
  66. */
  67. 'unique' => true,
  68. /**
  69. * If you are enforcing unique slugs, the default is to add an
  70. * incremental value to the end of the base slug. Alternatively, you
  71. * can change this value to a closure that accepts three parameters:
  72. * the base slug, the separator, and a Collection of the other
  73. * "similar" slugs. The closure should return the new unique
  74. * suffix to append to the slug.
  75. */
  76. 'uniqueSuffix' => null,
  77. /**
  78. * Should we include the trashed items when generating a unique slug?
  79. * This only applies if the softDelete property is set for the Eloquent model.
  80. * If set to "false", then a new slug could duplicate one that exists on a trashed model.
  81. * If set to "true", then uniqueness is enforced across trashed and existing models.
  82. */
  83. 'includeTrashed' => false,
  84. /**
  85. * An array of slug names that can never be used for this model,
  86. * e.g. to prevent collisions with existing routes or controller methods, etc..
  87. * Defaults to null (i.e. no reserved names).
  88. * Can be a static array, e.g.:
  89. *
  90. * 'reserved' => array('add', 'delete'),
  91. *
  92. * or a closure that returns an array of reserved names.
  93. * If using a closure, it will accept one parameter: the model itself, and should
  94. * return an array of reserved names, or null. e.g.
  95. *
  96. * 'reserved' => function( Model $model) {
  97. * return $model->some_method_that_returns_an_array();
  98. * }
  99. *
  100. * In the case of a slug that gets generated with one of these reserved names,
  101. * we will do:
  102. *
  103. * $slug .= $separator + "1"
  104. *
  105. * and continue from there.
  106. */
  107. 'reserved' => null,
  108. /**
  109. * Whether to update the slug value when a model is being
  110. * re-saved (i.e. already exists). Defaults to false, which
  111. * means slugs are not updated.
  112. *
  113. * Be careful! If you are using slugs to generate URLs, then
  114. * updating your slug automatically might change your URLs which
  115. * is probably not a good idea from an SEO point of view.
  116. * Only set this to true if you understand the possible consequences.
  117. */
  118. 'onUpdate' => false,
  119. /**
  120. * If the default slug engine of cocur/slugify is used, this array of
  121. * configuration options will be used when instantiating the engine.
  122. */
  123. 'slugEngineOptions' => [],
  124. ];