Example #1
0
 public static function getRelationModel($id, $relationType)
 {
     $model = Relation::where('model_name', $relationType)->where('model_id', $id)->first();
     if ($model) {
         return $relationType::find($model->relation_id);
     }
     return null;
 }
Example #2
0
 public function follow($user2_id)
 {
     $relation = Relation::where('user1_id', '=', $this->id)->where('user2_id', '=', $user2_id)->get()->first();
     if ($relation) {
         return $relation->type;
     } else {
         return 0;
     }
 }
Example #3
0
 public function postAjaxUnfollow()
 {
     if (!empty(Input::get('user_id')) && !empty(Input::get('current_user'))) {
         if (true) {
             $relation = Relation::where('user1_id', '=', Input::get('current_user'))->where('user2_id', '=', Input::get('user_id'))->get()->first();
             if ($relation->delete() == 1) {
                 echo 'true';
             }
         }
     } else {
         echo 'false';
     }
 }