/** * Handle Disable Target * * @param Integer $id * @return Response */ public function disable($id) { $target = Targets::findOrFail($id); $target->watched = 0; $target->disabled = 1; $target->save(); return redirect()->back()->with(['status' => 'success', 'message' => 'Target disabled.']); }
/** * Add Tweet to Queue * * @param Array $data * @return Response */ private function queue($input) { $data = array(); /** * Remove `tweet_` prefix */ foreach ($input as $key => $value) { if (strpos($key, 'tweet_') === 0) { $key = substr($key, 6); } $data[$key] = $value; } /** * If Sender or Target flagged, flag Tweet */ if (Senders::findOrFail($data['sender'])->flagged || Targets::findOrFail($data['target'])->watched) { $data['flagged'] = 1; } Tweets::create($data); /** * If Tweet Flagged, return Warning */ if ($data['flagged']) { return response()->json(['code' => 406, 'status' => 'flagged', 'message' => 'Tweet was flagged for moderation.']); } return response()->json(['code' => 200, 'status' => 'success', 'message' => 'Tweet added to the queue.']); }