/** * Execute the job. * * @return void */ public function handle() { // Someone triggered the conversation without mentioning the target user if (is_null($this->tweet['in_reply_to_user_id'])) { return; } $conversation = Conversation::create(['trigger_tweet_id' => $this->tweet['id_str'], 'sniper_user_id' => $this->tweet['user']['id_str'], 'sniper_user_screen_name' => $this->tweet['user']['screen_name'], 'sniper_user_utc_offset' => $this->tweet['user']['utc_offset'], 'target_user_id' => $this->tweet['in_reply_to_user_id_str'], 'target_user_screen_name' => $this->tweet['in_reply_to_screen_name'], 'story_id' => Story::random()->id]); $this->dispatch(new AnnoyTheTarget($conversation)); }
public function handle(Request $request, $id) { $conversation = Conversation::where(['from' => Auth::user()->id, 'to' => $id])->orWhere(['to' => Auth::user()->id, 'from' => $id])->first(); if (count($conversation) == 0) { $conversation = Conversation::create(['from' => Auth::user()->id, 'to' => $id]); } if ($request->get('content') != "" && Message::create(['from' => Auth::user()->id, 'to' => $id, 'content' => htmlentities($request->get('content')), 'conversation_id' => $conversation->id])) { $conversation->updated_at = date("Y-m-d H:i:s"); $conversation->save(); return json_encode(['error' => 0, 'message' => htmlentities($request->get('content')), 'reciever' => $id, 'avatar_url' => Auth::user()->getProfilePictureUrl(), 'type' => 0]); } return json_encode(['error' => 1, 'message' => 'Can not send message!', 'type' => -1]); }