public function addMember($id)
 {
     $team = Team::find($id);
     if ($team) {
         $newcomer = Newcomer::findOrFail((int) Request::input('newcomer'));
         $newcomer->team_id = $id;
         $newcomer->save();
         return $this->success('Le nouveau a été ajouté à l\'équipe !');
     }
     return $this->error('Équipe inconnue !');
 }
 public function checkIn($type, $id)
 {
     if ($type == "newcomers") {
         $user = Newcomer::findOrFail($id);
     } elseif ($type == "students") {
         $user = Student::findOrFail($id);
     } else {
         abort(404, 'Inconnu type');
     }
     $user->checkin = true;
     $user->save();
     return \Illuminate\Support\Facades\Redirect::back();
 }
 /**
  * Display one or multiple newcomer's letter
  *
  * @param  int $id
  * @param  int $limit
  * @param  string $category
  * @return Response
  */
 public function letter($id, $limit = null, $category = null)
 {
     if ($limit === null) {
         $newcomers = [Newcomer::findOrFail($id)];
     } elseif ($category != null) {
         $newcomers = Newcomer::where('branch', '=', strtoupper($category))->offset($id)->limit($limit)->get();
     } else {
         $newcomers = Newcomer::offset($id)->limit($limit)->get();
     }
     // Parse phone number and save it to db
     foreach ($newcomers as $newcomer) {
         if (isset($newcomer->referral->phone)) {
             if (preg_match('/^(?:0([0-9])|(?:00|\\+)33[\\. -]?([0-9]))[\\. -]?([0-9]{2})[\\. -]?([0-9]{2})[\\. -]?([0-9]{2})[\\. -]?([0-9]{2})[\\. -]?$/', $newcomer->referral->phone, $m) && $newcomer->referral->phone != '0' . $m[1] . $m[2] . '.' . $m[3] . '.' . $m[4] . '.' . $m[5] . '.' . $m[6]) {
                 $referral = $newcomer->referral;
                 $referral->phone = '0' . $m[1] . $m[2] . '.' . $m[3] . '.' . $m[4] . '.' . $m[5] . '.' . $m[6];
                 $referral->save();
             }
         }
     }
     return View::make('dashboard.newcomers.letter', ['newcomers' => $newcomers, 'i' => $id, 'count' => Newcomer::count()]);
 }