daily pastebin goal
51%
SHARE
TWEET

Untitled

a guest Feb 18th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  public function getTeste(){
  2.         $users = DB::table('users')->whereYear('created_at',2018)->get();
  3.         $usersArray = $this->getMeses($users);
  4.         return response()->json($usersArray);
  5.     }
  6.  
  7.     public function getMeses($object)
  8.     {
  9.         $meses = [];
  10.  
  11.         for ($i=1;$i<=12;$i++)
  12.         {
  13.             $meses[] = $object->filter(function ($value) use ($i){
  14.                 $mes = substr($value->created_at,5,2);
  15.                 if ($i<10)
  16.                     return $mes == '0' . $i;
  17.                 return $mes == $i;
  18.             })->count();
  19.         }
  20.         return $meses;
  21.  
  22.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top