all(); $array = [ 'privacy' => 'required', 'images' => 'array|required_without:description', 'images.*' => 'image|mimes:jpeg,png,jpg,gif|max:15360', 'description' => 'required_without:images', 'category_id' => 'required|exists:categories,id', 'type' => 'nullable|in:1,2,3', 'type_id' => 'nullable|exists:users,id', ]; $name = Route::currentRouteName(); if ($name == 'api.post.sant.store') { $array['type_id'] = 'required|exists:sants,id'; $array['type'] = 'required|in:2'; } if ($data['type'] == Constant::POST_TYPE_SANT) { $array['type_id'] = 'required|exists:sants,id'; $array['type'] = 'required|in:2'; } if ($data['type'] == Constant::POST_TYPE_SANGH) { $array['type_id'] = 'required|exists:sanghs,id'; $array['type'] = 'required|in:3'; } return $array; } }