You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.1 KiB

  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Http\Request;
  4. use Twitter;
  5. use App\Tweet, App\Events\NewTweetEvent;
  6. class DashboardController extends Controller
  7. {
  8. /**
  9. * Create a new controller instance.
  10. *
  11. * @return void
  12. */
  13. public function __construct()
  14. {
  15. $this->middleware('auth');
  16. }
  17. /**
  18. * Show the application dashboard.
  19. *
  20. * @return \Illuminate\Http\Response
  21. */
  22. public function index()
  23. {
  24. return view('dashboard', [
  25. ]);
  26. }
  27. public function queue() {
  28. Tweet::claimed_timeout();
  29. $tweets = Tweet::queued()->get();
  30. $queue = [];
  31. foreach($tweets as $tweet) {
  32. $queue[] = new NewTweetEvent($tweet);
  33. }
  34. return response()->json(['queue'=>$queue]);
  35. }
  36. public function claim_tweet(Request $request) {
  37. $tweet = Tweet::where('id', $request->input('tweet_id'))->first();
  38. if($tweet) {
  39. $tweet->claimed_at = date('Y-m-d H:i:s');
  40. $tweet->save();
  41. }
  42. return response()->json(['result'=>'ok']);
  43. }
  44. }