Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F120835886
GroupObserver.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
GroupObserver.php
View Options
<?php
namespace
App\Observers
;
use
App\EventLog
;
use
App\Group
;
use
App\Jobs\Group\CreateJob
;
use
App\Jobs\Group\DeleteJob
;
use
App\Jobs\Group\UpdateJob
;
class
GroupObserver
{
/**
* Handle the group "creating" event.
*
* @param Group $group The group
*/
public
function
creating
(
Group
$group
):
void
{
$group
->
status
|=
Group
::
STATUS_NEW
;
if
(!
isset
(
$group
->
name
)
&&
isset
(
$group
->
email
))
{
$group
->
name
=
explode
(
'@'
,
$group
->
email
)[
0
];
}
}
/**
* Handle the group "created" event.
*
* @param Group $group The group
*/
public
function
created
(
Group
$group
)
{
CreateJob
::
dispatch
(
$group
->
id
);
}
/**
* Handle the group "deleted" event.
*
* @param Group $group The group
*/
public
function
deleted
(
Group
$group
)
{
if
(
$group
->
isForceDeleting
())
{
// Remove EventLog records
EventLog
::
where
(
'object_id'
,
$group
->
id
)->
where
(
'object_type'
,
Group
::
class
)->
delete
();
return
;
}
DeleteJob
::
dispatch
(
$group
->
id
);
}
/**
* Handle the group "updated" event.
*
* @param Group $group The group
*/
public
function
updated
(
Group
$group
)
{
if
(!
$group
->
trashed
())
{
UpdateJob
::
dispatch
(
$group
->
id
);
}
}
/**
* Handle the group "restoring" event.
*
* @param Group $group The group
*/
public
function
restoring
(
Group
$group
)
{
// Reset the status
$group
->
status
=
Group
::
STATUS_NEW
;
// Note: $group->save() is invoked between 'restoring' and 'restored' events
}
/**
* Handle the group "restored" event.
*
* @param Group $group The group
*/
public
function
restored
(
Group
$group
)
{
CreateJob
::
dispatch
(
$group
->
id
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Apr 24, 1:23 PM (1 d, 6 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18820196
Default Alt Text
GroupObserver.php (1 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline