Un-butcher task system.

This commit is contained in:
Dane Everitt 2017-04-15 13:52:43 -04:00
parent 0fe9a4566e
commit 7f1a97184b
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
12 changed files with 154 additions and 77 deletions

View file

@ -320,7 +320,7 @@ class Server extends Model
*/
public function tasks()
{
return $this->hasMany(Task::class, 'server', 'id');
return $this->hasMany(Task::class);
}
/**

View file

@ -49,8 +49,10 @@ class Task extends Model
*/
protected $casts = [
'id' => 'integer',
'server' => 'integer',
'queued' => 'integer',
'user_id' => 'integer',
'server_id' => 'integer',
'queued' => 'boolean',
'active' => 'boolean',
];
/**
@ -59,4 +61,24 @@ class Task extends Model
* @var array
*/
protected $dates = ['last_run', 'next_run', 'created_at', 'updated_at'];
/**
* Gets the server associated with a task.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function server()
{
return $this->belongsTo(Server::class);
}
/**
* Gets the user associated with a task.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo(User::class);
}
}