<?php
|
|
namespace App;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use DB;
|
|
|
|
class Tweet extends Model
|
|
{
|
|
protected $fillable = [
|
|
'player_id', 'team_id', 'text', 'photo', 'claimed_at', 'processed', 'mission_id', 'tweet_date',
|
|
'm1_transit_line_id', 'm1_non_trimet',
|
|
'm2_transit_center_id', 'm2_with_other_team',
|
|
'm3_complete', 'm4_complete', 'm5_complete', 'm5_tip',
|
|
'm6_complete', 'm7_document_id'
|
|
];
|
|
|
|
public function team() {
|
|
return $this->belongsTo('\App\Team');
|
|
}
|
|
|
|
public function player() {
|
|
return $this->belongsTo('\App\Player');
|
|
}
|
|
|
|
public function mission() {
|
|
return $this->belongsTo('\App\Mission');
|
|
}
|
|
|
|
public static function claimed_timeout() {
|
|
DB::table('tweets')
|
|
->where('claimed_at', '<', date('Y-m-d H:i:s', time()-60)) // find tweets claimed longer than a minute ago
|
|
->update(['claimed_at' => null]);
|
|
}
|
|
|
|
public static function queued() {
|
|
return Tweet::whereNull('claimed_at')->where('processed', 0)->where('mission_id', '>', 0);
|
|
}
|
|
}
|