function run()
 {
     FriendRequest::truncate();
     $Request = new FriendRequest();
     $Request->sender_id = 11;
     $Request->recipient_id = 1;
     $Request->save();
     $Request = new FriendRequest();
     $Request->sender_id = 12;
     $Request->recipient_id = 2;
     $Request->save();
 }
 public function decline($id)
 {
     $Request = FriendRequest::find($id);
     if (!$Request) {
         echo json_encode(['success' => false]);
         return;
     }
     $result = $Request->delete();
     echo json_encode(['success' => (bool) $result]);
 }
Exemple #3
0
 public function actionRemovefriendrequest($id)
 {
     $friendRequest = FriendRequest::findById($id);
     if ($friendRequest) {
         $friendRequest->delete();
     } else {
         throw new \yii\web\NotFoundHttpException();
     }
     echo $this->renderAjax('friend_request', ['friendRequest' => $friendRequest]);
 }