public function assign()
 {
     DB::transaction(function () {
         $postCreatedTimestamp = strtotime($this->post['created_time']);
         $postCreatedTime = Carbon::createFromTimestamp($postCreatedTimestamp);
         //Save the post
         $socialPost = new SocialPost();
         $socialPost->type = 'facebook';
         $socialPost->post = json_encode($this->post);
         $socialPost->created_at = $postCreatedTime;
         $socialPost->save();
         //Assign social post to the user
         $userSocialPost = new UserSocialPost();
         $userSocialPost->user_id = $this->userId;
         $userSocialPost->social_post_id = $socialPost->id;
         $userSocialPost->created_at = $postCreatedTime;
         $userSocialPost->save();
     });
     return true;
 }
 public function assign()
 {
     DB::transaction(function () {
         if (!$this->checkPostInDB($this->post->id, $this->userId)) {
             $postCreatedTime = Carbon::createFromTimestamp($this->post->created_time);
             //Save the post
             $socialPost = new SocialPost();
             $socialPost->type = 'instagram';
             $socialPost->post = json_encode($this->post);
             $socialPost->created_at = $postCreatedTime;
             $socialPost->save();
             //Assign social post to the user
             $userSocialPost = new UserSocialPost();
             $userSocialPost->user_id = $this->userId;
             $userSocialPost->social_post_id = $socialPost->id;
             $userSocialPost->created_at = $postCreatedTime;
             $userSocialPost->save();
         }
     });
     return true;
 }