Example #1
0
 public function match_with($user, $rank)
 {
     $arr = $this->matches()->toArray();
     $match_exists = false;
     foreach ($arr as $matched_user) {
         if ($matched_user['matched_userid'] == $user->id) {
             $match_exists = true;
             break;
         }
     }
     if (!$match_exists) {
         $match = new Matched_user();
         $match->user_id = $this->id;
         $match->matched_userid = $user->id;
         $match->rank = $rank;
         $match->save();
     }
 }