功能:婚姻系统第8&10步(Controllers + Events + 路由)
- MarriageController:propose/accept/reject/divorce/confirmDivorce/status
- WeddingController:tiers/setup(立即触发)/claim/envelopeStatus
- 8个 WebSocket Events:
Marriage{Proposed|Accepted|Rejected|Expired|Divorced|DivorceRequested}
WeddingCelebration / EnvelopeClaimed
- 前台路由:marriage.* + wedding.*
- 后台路由:admin.marriages.*(superlevel 层)
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:离婚公告事件(广播至全房间)
|
||||
*
|
||||
* 触发时机:协议/强制/自动离婚完成后广播。
|
||||
* 强制离婚时额外显示财产转移信息。
|
||||
*
|
||||
* @author ChatRoom Laravel
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Marriage;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class MarriageDivorced implements ShouldBroadcastNow
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
/**
|
||||
* @param Marriage $marriage 婚姻记录
|
||||
* @param string $divorceType 离婚类型(mutual|forced|auto|admin)
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly Marriage $marriage,
|
||||
public readonly string $divorceType,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 广播至全房间。
|
||||
*
|
||||
* @return array<int, \Illuminate\Broadcasting\Channel>
|
||||
*/
|
||||
public function broadcastOn(): array
|
||||
{
|
||||
return [new PresenceChannel('room.1')];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function broadcastWith(): array
|
||||
{
|
||||
$this->marriage->load(['user:id,username', 'partner:id,username']);
|
||||
|
||||
return [
|
||||
'user_username' => $this->marriage->user?->username,
|
||||
'partner_username' => $this->marriage->partner?->username,
|
||||
'divorce_type' => $this->divorceType,
|
||||
];
|
||||
}
|
||||
|
||||
/** 广播事件名称。 */
|
||||
public function broadcastAs(): string
|
||||
{
|
||||
return 'marriage.divorced';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user