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

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Twitter;
use App\Tweet, App\Events\NewTweetEvent;
class DashboardController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->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 claim_tweet(Request $request) {
$tweet = Tweet::where('id', $request->input('tweet_id'))->first();
if($tweet) {
$tweet->claimed_at = date('Y-m-d H:i:s');
$tweet->save();
}
return response()->json(['result'=>'ok']);
}
}