repository.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. /*
  12. |--------------------------------------------------------------------------
  13. | Repository Pagination Limit Default
  14. |--------------------------------------------------------------------------
  15. |
  16. */
  17. 'pagination' => [
  18. 'limit' => 15,
  19. ],
  20. /*
  21. |--------------------------------------------------------------------------
  22. | Fractal Presenter Config
  23. |--------------------------------------------------------------------------
  24. |
  25. Available serializers:
  26. ArraySerializer
  27. DataArraySerializer
  28. JsonApiSerializer
  29. */
  30. 'fractal' => [
  31. 'params' => [
  32. 'include' => 'include',
  33. ],
  34. 'serializer' => \Jiannei\Response\Laravel\Support\Serializers\ArraySerializer::class,
  35. ],
  36. /*
  37. |--------------------------------------------------------------------------
  38. | Cache Config
  39. |--------------------------------------------------------------------------
  40. |
  41. */
  42. 'cache' => [
  43. /*
  44. |--------------------------------------------------------------------------
  45. | Cache Status
  46. |--------------------------------------------------------------------------
  47. |
  48. | Enable or disable cache
  49. |
  50. */
  51. 'enabled' => false,
  52. /*
  53. |--------------------------------------------------------------------------
  54. | Cache Minutes
  55. |--------------------------------------------------------------------------
  56. |
  57. | Time of expiration cache
  58. |
  59. */
  60. 'minutes' => 30,
  61. /*
  62. |--------------------------------------------------------------------------
  63. | Cache Repository
  64. |--------------------------------------------------------------------------
  65. |
  66. | Instance of Illuminate\Contracts\Cache\Repository
  67. |
  68. */
  69. 'repository' => 'cache',
  70. /*
  71. |--------------------------------------------------------------------------
  72. | Cache Clean Listener
  73. |--------------------------------------------------------------------------
  74. |
  75. |
  76. |
  77. */
  78. 'clean' => [
  79. /*
  80. |--------------------------------------------------------------------------
  81. | Enable clear cache on repository changes
  82. |--------------------------------------------------------------------------
  83. |
  84. */
  85. 'enabled' => true,
  86. /*
  87. |--------------------------------------------------------------------------
  88. | Actions in Repository
  89. |--------------------------------------------------------------------------
  90. |
  91. | create : Clear Cache on create Entry in repository
  92. | update : Clear Cache on update Entry in repository
  93. | delete : Clear Cache on delete Entry in repository
  94. |
  95. */
  96. 'on' => [
  97. 'create' => true,
  98. 'update' => true,
  99. 'delete' => true,
  100. ],
  101. ],
  102. 'params' => [
  103. /*
  104. |--------------------------------------------------------------------------
  105. | Skip Cache Params
  106. |--------------------------------------------------------------------------
  107. |
  108. |
  109. | Ex: http://prettus.local/?search=lorem&skipCache=true
  110. |
  111. */
  112. 'skipCache' => 'skipCache',
  113. ],
  114. /*
  115. |--------------------------------------------------------------------------
  116. | Methods Allowed
  117. |--------------------------------------------------------------------------
  118. |
  119. | methods cacheable : all, paginate, find, findByField, findWhere, getByCriteria
  120. |
  121. | Ex:
  122. |
  123. | 'only' =>['all','paginate'],
  124. |
  125. | or
  126. |
  127. | 'except' =>['find'],
  128. */
  129. 'allowed' => [
  130. 'only' => null,
  131. 'except' => null,
  132. ],
  133. ],
  134. /*
  135. |--------------------------------------------------------------------------
  136. | Criteria Config
  137. |--------------------------------------------------------------------------
  138. |
  139. | Settings of request parameters names that will be used by Criteria
  140. |
  141. */
  142. 'criteria' => [
  143. /*
  144. |--------------------------------------------------------------------------
  145. | Accepted Conditions
  146. |--------------------------------------------------------------------------
  147. |
  148. | Conditions accepted in consultations where the Criteria
  149. |
  150. | Ex:
  151. |
  152. | 'acceptedConditions'=>['=','like']
  153. |
  154. | $query->where('foo','=','bar')
  155. | $query->where('foo','like','bar')
  156. |
  157. */
  158. 'acceptedConditions' => [
  159. '=',
  160. 'like',
  161. ],
  162. /*
  163. |--------------------------------------------------------------------------
  164. | Request Params
  165. |--------------------------------------------------------------------------
  166. |
  167. | Request parameters that will be used to filter the query in the repository
  168. |
  169. | Params :
  170. |
  171. | - search : Searched value
  172. | Ex: http://prettus.local/?search=lorem
  173. |
  174. | - searchFields : Fields in which research should be carried out
  175. | Ex:
  176. | http://prettus.local/?search=lorem&searchFields=name;email
  177. | http://prettus.local/?search=lorem&searchFields=name:like;email
  178. | http://prettus.local/?search=lorem&searchFields=name:like
  179. |
  180. | - filter : Fields that must be returned to the response object
  181. | Ex:
  182. | http://prettus.local/?search=lorem&filter=id,name
  183. |
  184. | - orderBy : Order By
  185. | Ex:
  186. | http://prettus.local/?search=lorem&orderBy=id
  187. |
  188. | - sortedBy : Sort
  189. | Ex:
  190. | http://prettus.local/?search=lorem&orderBy=id&sortedBy=asc
  191. | http://prettus.local/?search=lorem&orderBy=id&sortedBy=desc
  192. |
  193. | - searchJoin: Specifies the search method (AND / OR), by default the
  194. | application searches each parameter with OR
  195. | EX:
  196. | http://prettus.local/?search=lorem&searchJoin=and
  197. | http://prettus.local/?search=lorem&searchJoin=or
  198. |
  199. */
  200. 'params' => [
  201. 'search' => 'search',
  202. 'searchFields' => 'searchFields',
  203. 'filter' => 'filter',
  204. 'orderBy' => 'orderBy',
  205. 'sortedBy' => 'sortedBy',
  206. 'with' => 'with',
  207. 'searchJoin' => 'searchJoin',
  208. 'withCount' => 'withCount',
  209. 'cursor' => 'cursor',
  210. ],
  211. ],
  212. /*
  213. |--------------------------------------------------------------------------
  214. | Generator Config
  215. |--------------------------------------------------------------------------
  216. |
  217. */
  218. 'generator' => [
  219. 'basePath' => app()->path(),
  220. 'rootNamespace' => 'App\\',
  221. 'stubsOverridePath' => app()->path(),
  222. 'paths' => [
  223. 'models' => 'Repositories\\Models',
  224. 'repositories' => 'Repositories\\Eloquent',
  225. 'interfaces' => 'Contracts\\Repositories',
  226. 'transformers' => 'Repositories\\Transformers',
  227. 'presenters' => 'Repositories\\Presenters',
  228. 'validators' => 'Repositories\\Validators',
  229. 'controllers' => 'Http/Controllers',
  230. 'provider' => 'RepositoryServiceProvider',
  231. 'criteria' => 'Repositories\\Criteria',
  232. ],
  233. ],
  234. ];