Exemple #1
0
 public function detail($id)
 {
     $user = User::find($id);
     try {
         if (!is_null($user)) {
             $user->count = $user->email()->count();
             $user->emails = $user->email()->get();
             $data = Citrus::response('data', $user);
         } else {
             throw new Exception('User not found');
         }
     } catch (Exception $e) {
         $data = Citrus::response('error', $e);
     }
     return $data;
 }
Exemple #2
0
 public function leaderboard()
 {
     $users = User::all();
     $data = array();
     try {
         /*foreach ($users as $user) {
         				$data[$user->id] = $user->email()->count();
         			}
         			ksort($data);
         
         			//dd($user->email()->count());
         
         			$counter = 1;*/
         foreach ($users as $user) {
             $emails = $user->email()->count();
             $data[$user->id] = array('emails' => $emails, 'user' => Sentry::findUserById($user->id));
         }
         array_multisort($data, SORT_DESC);
         $response = Citrus::response('data', $data);
     } catch (Exception $e) {
         $response = Citrus::response('error', $e);
     }
     return $response;
 }
Exemple #3
0
 public function custom()
 {
     $user = Sentry::getUser();
     $input = Input::all();
     try {
         if ($user->id != 1) {
             throw new Exception("You do not have valid permissions to perform this action");
         }
         $teachers = Email::where('mass', '=', false)->take(25)->get();
         $email = new UtilityMailman();
         $email->setSubject($input['subject']);
         $email->setBody(nl2br($input['body']));
         //Decide if the response data should be parsed by Citrus
         $email->setReportStatus(0);
         // Where the attempted emails are stored
         $array = array();
         // Number of emails attempted
         $counter = 0;
         foreach ($teachers as $teacher) {
             $email->setReceiver($teacher->to);
             if (!is_null($teacher->name)) {
                 $email->name = $teacher->name;
             } else {
                 $email->name = $teacher->company;
             }
             $array[] = array('to' => $teacher->to, 'school' => $teacher->company, 'status' => $email->send(null, $teacher), 'name' => $teacher->name);
             if ($array[0]['status'] == 1) {
                 $teacher->mass = 1;
                 $teacher->save();
             }
             $counter = $counter + 1;
         }
         $data = Citrus::combine('total', $counter . ' messages were attempted', 'report', $array);
     } catch (Exception $e) {
         $data = Citrus::response('error', $e);
     }
     return $data;
 }
Exemple #4
0
 public static function combine()
 {
     $data = array();
     $args = func_num_args();
     $argDecider = 0;
     for ($i = 0; $i < $args / 2; $i++) {
         $index = func_get_arg($argDecider);
         $object = func_get_arg($argDecider + 1);
         $array[$index] = $object;
         $argDecider = $argDecider + 2;
     }
     $data = Citrus::build($array);
     $response = Citrus::response('data', $data);
     return $response;
 }
Exemple #5
0
 public function subscribe()
 {
     $email = Input::get('email');
     $subscribe = new Subscribe();
     $subscribe->email = $email;
     try {
         $subscribe->save();
         $data = Citrus::response('data', 'You have been successfully subscribed');
     } catch (Exception $e) {
         //$e->setMessage('You are already subscribed!');
         $data = Citrus::response('error', $e);
     }
     return $data;
 }