Improves server model and cleans up model code calls.

This commit is contained in:
Dane Everitt 2017-02-05 19:19:46 -05:00
parent b1389262e2
commit 02458c909d
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
8 changed files with 71 additions and 80 deletions

View file

@ -55,33 +55,8 @@ class Subuser extends Model
*
* @var array
*/
protected $casts = [
'user_id' => 'integer',
'server_id' => 'integer',
];
/**
* @var mixed
*/
protected static $user;
/**
* Constructor.
*/
public function __construct()
{
self::$user = Auth::user();
}
/**
* Returns an array of each server ID that the user has access to.
*
* @return array
*/
public static function accessServers()
{
$union = self::select('server_id')->where('user_id', self::$user->id);
return Server::select('id')->where('owner', self::$user->id)->union($union)->pluck('id');
}
protected $casts = [
'user_id' => 'integer',
'server_id' => 'integer',
];
}