|
@@ -501,6 +501,7 @@ class NewsService implements NewsServiceInterface
|
|
|
$where['sur_id'] = $survey['sur_id'];
|
|
|
// $query = ArticleSurvey::where('sur_id',$survey['sur_id']);
|
|
|
}
|
|
|
+ // return Result::success($where);
|
|
|
$result = ArticleSurvey::where($where)
|
|
|
->where(function ($query) {
|
|
|
$query->where('is_other', 0)
|
|
@@ -564,7 +565,7 @@ class NewsService implements NewsServiceInterface
|
|
|
*/
|
|
|
public function addWebsiteSurveyVote(array $data): array
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
if(isset($data['website_id']) && !empty($data['website_id'])){
|
|
|
$website = Website::where('id',$data['website_id'])->first();
|
|
|
if(empty($website)){
|
|
@@ -603,11 +604,20 @@ class NewsService implements NewsServiceInterface
|
|
|
->where('is_other',1)
|
|
|
->where('other_id','!=',0)
|
|
|
->first();
|
|
|
- // return Result::success($data);
|
|
|
+ // return Result::success($choice['other']);
|
|
|
$choice_id = $data['choice_id'];
|
|
|
if(!empty($choice['other'])){
|
|
|
array_push($data['choice_id'],$choice['other']['other_id']);
|
|
|
- $choice_id[0] = $choice['other']['other_id'];
|
|
|
+ if(!empty($choice_id)){
|
|
|
+ $key = array_search($choice['other']['id'], $choice_id);
|
|
|
+ if ($key!== false) {
|
|
|
+ unset($choice_id[$key]);
|
|
|
+ $choice_id = array_values($choice_id);
|
|
|
+ }
|
|
|
+ array_push($choice_id,$choice['other']['other_id']);
|
|
|
+ }else{
|
|
|
+ $choice_id[0] = $choice['other']['other_id'];
|
|
|
+ }
|
|
|
// return Result::success($data['choice_id']);
|
|
|
}
|
|
|
// return Result::success($data);
|