gq 7 år sedan
förälder
incheckning
7d5bca4fb9
1 ändrade filer med 7 tillägg och 7 borttagningar
  1. 7 7
      server/app/Http/Controllers/Api/V1/IndexController.php

+ 7 - 7
server/app/Http/Controllers/Api/V1/IndexController.php

xqd
@@ -359,37 +359,37 @@ class IndexController extends Controller
                 switch ($value) {
                     case 1:
                         $query = $query->orWhereHas('user', function ($select) use ($age) {
-                            $select->where('birthday','>=',date('Y-m-d',strtotime(date('Y')-21)))->where('birthday','<=',date('Y-m-d',strtotime(date('Y')-18)));
+                            $select->whereYear('birthday','>=',date('Y-m-d',strtotime(date('Y')-21)))->whereYear('birthday','<=',date('Y-m-d',strtotime(date('Y')-18)));
                         });
                         break;
                     case 2:
                         $query = $query->orWhereHas('user', function ($select) use ($age) {
-                            $select->where('birthday','>=',date('Y-m-d',strtotime(date('Y')-25)))->where('birthday','<=',date('Y-m-d',strtotime(date('Y')-22)));
+                            $select->whereYear('birthday','>=',date('Y-m-d',strtotime(date('Y')-25)))->whereYear('birthday','<=',date('Y-m-d',strtotime(date('Y')-22)));
                         });
                         break;
                     case 3:
                         $query = $query->orWhereHas('user', function ($select) use ($age) {
-                            $select->where('birthday','>=',date('Y-m-d',strtotime(date('Y')-29)))->where('birthday','<=',date('Y-m-d',strtotime(date('Y')-26)));
+                            $select->whereYear('birthday','>=',date('Y-m-d',strtotime(date('Y')-29)))->whereYear('birthday','<=',date('Y-m-d',strtotime(date('Y')-26)));
                         });
                         break;
                     case 4:
                         $query = $query->orWhereHas('user', function ($select) use ($age) {
-                            $select->where('birthday','>=',date('Y-m-d',strtotime(date('Y')-33)))->where('birthday','<=',date('Y-m-d',strtotime(date('Y')-30)));
+                            $select->whereYear('birthday','>=',date('Y-m-d',strtotime(date('Y')-33)))->whereYear('birthday','<=',date('Y-m-d',strtotime(date('Y')-30)));
                         });
                         break;
                     case 5:
                         $query = $query->orWhereHas('user', function ($select) use ($age) {
-                            $select->where('birthday','>=',date('Y-m-d',strtotime(date('Y')-37)))->where('birthday','<=',date('Y-m-d',strtotime(date('Y')-34)));
+                            $select->whereYear('birthday','>=',date('Y-m-d',strtotime(date('Y')-37)))->whereYear('birthday','<=',date('Y-m-d',strtotime(date('Y')-34)));
                         });
                         break;
                     case 6:
                         $query = $query->orWhereHas('user', function ($select) use ($age) {
-                            $select->where('birthday','>=',date('Y-m-d',strtotime(date('Y')-38)));
+                            $select->whereYear('birthday','>=',date('Y-m-d',strtotime(date('Y')-38)));
                         });
                         break;
                     case 7:
                         $query = $query->orWhereHas('user', function ($select) use ($age) {
-                            $select->where('birthday','<=',date('Y-m-d',strtotime(date('Y')-18)));
+                            $select->whereYear('birthday','<=',date('Y-m-d',strtotime(date('Y')-17)));
                         });
                         break;
                 }