Skip to content

Commit 223c0eb

Browse files
committed
fix: update validation rules for documents and image gallery in PostsRequest
1 parent 083abc4 commit 223c0eb

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/Http/Requests/PostsRequest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ public function rules(): array
2727
$post = $this->route('post');
2828

2929
$rules = [
30-
'title' => 'string|max:500',
31-
'slug' => 'string|max:255',
32-
'content' => 'nullable|string',
33-
'excerpt' => 'nullable|string|max:500',
34-
'status' => 'nullable|string|in:draft,published,pending',
35-
'published_at' => 'nullable|date',
36-
'featured_image' => 'nullable',
37-
'hide_translation' => 'boolean',
38-
'menu_order' => 'nullable|integer|between:0,9999999',
30+
'title' => 'string|max:500',
31+
'slug' => 'string|max:255',
32+
'content' => 'nullable|string',
33+
'excerpt' => 'nullable|string|max:500',
34+
'status' => 'nullable|string|in:draft,published,pending',
35+
'published_at' => 'nullable|date',
36+
'featured_image' => 'nullable',
37+
'hide_translation' => 'boolean',
38+
'menu_order' => 'nullable|integer|between:0,9999999',
3939
];
4040

4141
// Categories validation if post type has categories feature
@@ -54,11 +54,11 @@ public function rules(): array
5454

5555
// Documents validation
5656
$rules['documents'] = 'nullable|array';
57-
$rules['documents.*'] = 'file|mimes:pdf,doc,docx,xls,xlsx,ppt,pptx|max:51200';
57+
$rules['documents.*'] = 'exists:media,id';
5858

5959
// Image gallery validation
6060
$rules['image_gallery'] = 'nullable|array';
61-
$rules['image_gallery.*'] = 'file|mimes:jpeg,jpg,png,gif,webp|max:10240';
61+
$rules['image_gallery.*'] = 'exists:media,id';
6262

6363
// Expiry validation
6464
$published_at = $this->input('published_at') ?? optional($post)->published_at;
@@ -82,7 +82,7 @@ public function rules(): array
8282
$rules['recently_updated'] = 'nullable|boolean';
8383

8484
// On create, make required fields
85-
if (! $post) {
85+
if (!$post) {
8686
$rules['title'] .= '|required';
8787
$rules['slug'] .= '|required';
8888
}

0 commit comments

Comments
 (0)