@@ -102,6 +102,60 @@ public function rules()
102102 return [];
103103 }
104104
105+ /**
106+ * Get custom attributes for validator errors that apply to the request.
107+ *
108+ * @return array
109+ */
110+ public function messages ()
111+ {
112+ if (!$ this ->route ()) {
113+ return [];
114+ }
115+
116+ if ($ this ->route ()->getActionMethod () === 'store ' ) {
117+ return array_merge ($ this ->commonMessages (), $ this ->storeMessages ());
118+ }
119+
120+ if ($ this ->route ()->getActionMethod () === 'batchStore ' ) {
121+ return array_merge ($ this ->commonMessages (), $ this ->storeMessages (), $ this ->batchStoreMessages ());
122+ }
123+
124+ if ($ this ->route ()->getActionMethod () === 'update ' ) {
125+ return array_merge ($ this ->commonMessages (), $ this ->updateMessages ());
126+ }
127+
128+ if ($ this ->route ()->getActionMethod () === 'batchUpdate ' ) {
129+ return array_merge ($ this ->commonMessages (), $ this ->updateMessages (), $ this ->batchUpdateMessages ());
130+ }
131+
132+ if ($ this ->route ()->getActionMethod () === 'associate ' ) {
133+ return $ this ->associateMessages ();
134+ }
135+
136+ if ($ this ->route ()->getActionMethod () === 'attach ' ) {
137+ return $ this ->attachMessages ();
138+ }
139+
140+ if ($ this ->route ()->getActionMethod () === 'detach ' ) {
141+ return $ this ->detachMessages ();
142+ }
143+
144+ if ($ this ->route ()->getActionMethod () === 'sync ' ) {
145+ return $ this ->syncMessages ();
146+ }
147+
148+ if ($ this ->route ()->getActionMethod () === 'toggle ' ) {
149+ return $ this ->toggleMessages ();
150+ }
151+
152+ if ($ this ->route ()->getActionMethod () === 'updatePivot ' ) {
153+ return $ this ->updatePivotMessages ();
154+ }
155+
156+ return [];
157+ }
158+
105159 /**
106160 * Default rules for the request.
107161 *
@@ -226,4 +280,114 @@ public function updatePivotRules(): array
226280 {
227281 return [];
228282 }
283+
284+ /**
285+ * Default messages for the request.
286+ *
287+ * @return array
288+ */
289+ public function commonMessages (): array
290+ {
291+ return [];
292+ }
293+
294+ /**
295+ * Messages for the "store" (POST) endpoint.
296+ *
297+ * @return array
298+ */
299+ function storeMessages (): array
300+ {
301+ return [];
302+ }
303+
304+ /**
305+ * Messages for the "batchstore" (POST) endpoint.
306+ *
307+ * @return array
308+ */
309+ function batchStoreMessages (): array
310+ {
311+ return [];
312+ }
313+
314+ /**
315+ * Messages for the "update" (POST) endpoint.
316+ *
317+ * @return array
318+ */
319+ function updateMessages (): array
320+ {
321+ return [];
322+ }
323+
324+ /**
325+ * Messages for the "batchUpdate" (POST) endpoint.
326+ *
327+ * @return array
328+ */
329+ function batchUpdateMessages (): array
330+ {
331+ return [];
332+ }
333+
334+ /**
335+ * Messages for the "associate" endpoint.
336+ *
337+ * @return array
338+ */
339+ public function associateMessages (): array
340+ {
341+ return [];
342+ }
343+
344+ /**
345+ * Messages for the "attach" endpoint.
346+ *
347+ * @return array
348+ */
349+ public function attachMessages (): array
350+ {
351+ return [];
352+ }
353+
354+ /**
355+ * Messages for the "detach" endpoint.
356+ *
357+ * @return array
358+ */
359+ public function detachMessages (): array
360+ {
361+ return [];
362+ }
363+
364+ /**
365+ * Messages for the "sync" endpoint.
366+ *
367+ * @return array
368+ */
369+ public function syncMessages (): array
370+ {
371+ return [];
372+ }
373+
374+ /**
375+ * Messages for the "toggle" endpoint.
376+ *
377+ * @return array
378+ */
379+ public function toggleMessages (): array
380+ {
381+ return [];
382+ }
383+
384+ /**
385+ * Messages for the "pivot" endpoint.
386+ *
387+ * @return array
388+ */
389+ public function updatePivotMessages (): array
390+ {
391+ return [];
392+ }
229393}
0 commit comments