mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-12-02 05:03:52 +01:00
89 lines
1.6 KiB
PHP
89 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Events\GroupDeleting;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
/**
|
|
* @property int $twofaccounts_count
|
|
*/
|
|
class Group extends Model
|
|
{
|
|
|
|
use HasFactory;
|
|
|
|
/**
|
|
* model's array form.
|
|
*
|
|
* @var string[]
|
|
*/
|
|
protected $fillable = ['name'];
|
|
|
|
|
|
/**
|
|
* The accessors to append to the model's array form.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $appends = [];
|
|
|
|
|
|
/**
|
|
* The attributes that should be hidden for arrays.
|
|
*
|
|
* @var array<int, string>
|
|
*/
|
|
protected $hidden = ['created_at', 'updated_at'];
|
|
|
|
|
|
/**
|
|
* The attributes that should be cast.
|
|
*
|
|
* @var array<string, string>
|
|
*/
|
|
protected $casts = [
|
|
'twofaccounts_count' => 'integer',
|
|
];
|
|
|
|
|
|
/**
|
|
* The event map for the model.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $dispatchesEvents = [
|
|
'deleting' => GroupDeleting::class,
|
|
];
|
|
|
|
|
|
/**
|
|
* Override The "booting" method of the model
|
|
*
|
|
* @return void
|
|
*/
|
|
protected static function boot()
|
|
{
|
|
parent::boot();
|
|
|
|
static::deleted(function (object $model) {
|
|
// @codeCoverageIgnoreStart
|
|
Log::info(sprintf('Group %s deleted', var_export($model->name, true)));
|
|
// @codeCoverageIgnoreEnd
|
|
});
|
|
}
|
|
|
|
|
|
/**
|
|
* Get the TwoFAccounts of the group.
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
*/
|
|
public function twofaccounts()
|
|
{
|
|
return $this->hasMany(\App\Models\TwoFAccount::class);
|
|
}
|
|
}
|