2020-10-25 23:50:13 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App;
|
|
|
|
|
|
|
|
use App\Classes\Options;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class Group extends Model
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* model's array form.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $fillable = ['name'];
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The accessors to append to the model's array form.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $appends = ['isActive'];
|
|
|
|
|
|
|
|
|
2020-11-21 21:50:33 +01:00
|
|
|
/**
|
|
|
|
* The attributes that should be hidden for arrays.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $hidden = ['created_at', 'updated_at'];
|
|
|
|
|
|
|
|
|
2020-11-23 12:54:06 +01:00
|
|
|
/**
|
|
|
|
* The attributes that should be cast.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $casts = [
|
|
|
|
'twofaccounts_count' => 'integer',
|
|
|
|
];
|
|
|
|
|
|
|
|
|
2020-10-25 23:50:13 +01:00
|
|
|
/**
|
|
|
|
* Get the TwoFAccounts of the group.
|
|
|
|
*/
|
|
|
|
public function twofaccounts()
|
|
|
|
{
|
|
|
|
return $this->hasMany('App\TwoFAccount');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the group
|
|
|
|
*
|
|
|
|
* @return integer
|
|
|
|
*/
|
|
|
|
public function getIsActiveAttribute()
|
|
|
|
{
|
|
|
|
$activeGroupId = intval(Options::get('activeGroup'));
|
|
|
|
|
|
|
|
return $this->id === $activeGroupId ? true : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|