Files
Global-Jain/app/Http/Requests/Api/Post/UpdatePostRequest.php
2025-11-05 10:37:10 +05:30

43 lines
999 B
PHP

<?php
namespace App\Http\Requests\Api\Post;
use Illuminate\Foundation\Http\FormRequest;
class UpdatePostRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$array = [
'privacy' => 'required',
'images' => 'array|required_without:description',
'images.*' => 'image|mimes:jpeg,png,jpg|max:15360',
'description' => 'required_without:images',
'category_id' => 'required|exists:categories,id',
'removed_image_id' => 'array'
];
if ($this->post->postImages()->exists()) {
$array['description'] = 'nullable';
$array['images'] = 'array';
}
return $array;
}
}