22
33namespace App \Http \Requests \ComputerScienceResource ;
44
5+ use App \Http \Requests \Shared \ComputerScienceResourceRequest ;
56use Auth ;
67use Illuminate \Foundation \Http \FormRequest ;
7- use Illuminate \Validation \Rule ;
88
99class StoreResourceRequest extends FormRequest
1010{
11+ use ComputerScienceResourceRequest;
12+
1113 /**
1214 * Determine if the user is authorized to make this request.
1315 */
@@ -23,23 +25,11 @@ public function authorize(): bool
2325 */
2426 public function rules (): array
2527 {
26- return [
27- 'name ' => ['required ' , 'string ' , 'max:100 ' ],
28- 'description ' => ['required ' , 'string ' , 'max:10000 ' ],
29- 'platforms ' => ['required ' , 'array ' ],
30- 'platforms.* ' => ['distinct ' , 'string ' , Rule::in (config ('computerScienceResource.platforms ' ))],
31- 'page_url ' => ['required ' , 'string ' , 'url:http,https ' , 'max:255 ' ],
32- 'difficulty ' => ['required ' , 'string ' , Rule::in (config ('computerScienceResource.difficulties ' ))],
33- 'pricing ' => ['required ' , 'string ' , Rule::in (config ('computerScienceResource.pricings ' ))],
34- 'topic_tags ' => ['required ' , 'array ' , 'min:3 ' ],
35- 'topic_tags.* ' => ['required ' , 'distinct ' , 'string ' , 'max:50 ' ],
36-
37- // Optional fields
38- 'image_url ' => ['nullable ' , 'string ' , 'url:http,https ' , 'max:255 ' ],
28+ return array_merge ($ this ->baseResourceRules (), [
3929 'general_tags ' => ['nullable ' , 'array ' ],
4030 'general_tags.* ' => ['distinct ' , 'string ' , 'max:50 ' ],
4131 'programming_language_tags ' => ['nullable ' , 'array ' ],
42- 'programming_language_tags.* ' => ['distinct ' , 'string ' , 'max:50 ' ]
43- ];
32+ 'programming_language_tags.* ' => ['distinct ' , 'string ' , 'max:50 ' ],
33+ ]) ;
4434 }
4535}
0 commit comments