/home/techb158/immovalet.com/platform/core/acl/src/Models
Edit: /home/techb158/immovalet.com/platform/core/acl/src/Models/Role.php (1994B)
'json',
];
/**
* @param string $value
* @return array
*/
public function getPermissionsAttribute($value)
{
try {
return json_decode($value, true) ?: [];
} catch (Exception $exception) {
return [];
}
}
/**
* Set mutator for the "permissions" attribute.
*
* @param array $permissions
* @return void
*/
public function setPermissionsAttribute(array $permissions)
{
$this->attributes['permissions'] = $permissions ? json_encode($permissions) : '';
}
/**
* {@inheritDoc}
*/
public function delete()
{
if ($this->exists) {
$this->users()->detach();
}
return parent::delete();
}
/**
* @return BelongsToMany
*/
public function users()
{
return $this->belongsToMany(User::class, 'role_users', 'role_id', 'user_id')->withTimestamps();
}
/**
* @return BelongsTo
*/
public function author()
{
return $this->belongsTo(User::class, 'created_by')->withDefault();
}
}