php-tenant/Events/WorkspaceOwnershipTransferred.php

45 lines
1.1 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace Core\Tenant\Events;
use Core\Tenant\Models\User;
use Core\Tenant\Models\Workspace;
use Illuminate\Foundation\Events\Dispatchable;
/**
* Event dispatched when workspace ownership is transferred to another member.
*
* ## Event Payload
*
* - `workspace`: The affected Workspace model
* - `previousOwner`: The User who was the previous owner (now demoted to admin)
* - `newOwner`: The User who is the new owner
*
* ## Usage
*
* ```php
* Event::listen(WorkspaceOwnershipTransferred::class, function ($event) {
* // Notify relevant parties, log audit trail, etc.
* });
* ```
*/
class WorkspaceOwnershipTransferred
{
use Dispatchable;
/**
* Create a new event instance.
*
* @param Workspace $workspace The workspace whose ownership was transferred
* @param User $previousOwner The user who was the previous owner
* @param User $newOwner The user who is now the owner
*/
public function __construct(
public readonly Workspace $workspace,
public readonly User $previousOwner,
public readonly User $newOwner,
) {}
}