middleware('auth'); } /** * Show the application dashboard. * * @return \Illuminate\Http\Response */ public function index() { return view('dashboard', [ ]); } public function queue() { Tweet::claimed_timeout(); $tweets = Tweet::queued()->get(); $queue = []; foreach($tweets as $tweet) { $queue[] = new NewTweetEvent($tweet); } return response()->json(['queue'=>$queue]); } public function ping() { Tweet::claimed_timeout(); return response()->json(['result'=>'ok']); } public function claim_tweet(Request $request) { $tweet = Tweet::where('id', $request->input('tweet_id'))->first(); if($tweet) { if($request->input('status') == 'unclaimed') { $tweet->claimed_at = null; $tweet->save(); event(new NewTweetEvent($tweet)); } else { $tweet->claimed_at = date('Y-m-d H:i:s'); $tweet->save(); // Broadcast that this tweet was claimed event(new TweetClaimedEvent($tweet)); } } return response()->json(['result'=>'ok']); } }