- 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 层)
61 lines
1.5 KiB
PHP
61 lines
1.5 KiB
PHP
<?php
|
|
|
|
/**
|
|
* 文件功能:求婚被拒事件(广播至求婚方私人频道)
|
|
*
|
|
* 触发时机:对方拒绝求婚,戒指消失后广播。
|
|
*
|
|
* @author ChatRoom Laravel
|
|
*
|
|
* @version 1.0.0
|
|
*/
|
|
|
|
namespace App\Events;
|
|
|
|
use App\Models\Marriage;
|
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
|
use Illuminate\Broadcasting\PrivateChannel;
|
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
|
use Illuminate\Foundation\Events\Dispatchable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class MarriageRejected implements ShouldBroadcastNow
|
|
{
|
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
|
|
|
/**
|
|
* @param Marriage $marriage 婚姻记录
|
|
*/
|
|
public function __construct(
|
|
public readonly Marriage $marriage,
|
|
) {}
|
|
|
|
/**
|
|
* 广播至求婚方私人频道。
|
|
*
|
|
* @return array<int, \Illuminate\Broadcasting\Channel>
|
|
*/
|
|
public function broadcastOn(): array
|
|
{
|
|
return [new PrivateChannel('user.'.$this->marriage->user_id)];
|
|
}
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function broadcastWith(): array
|
|
{
|
|
return [
|
|
'partner_username' => $this->marriage->partner?->username,
|
|
'ring_name' => $this->marriage->ringItem?->name,
|
|
'message' => '对方拒绝了您的求婚,戒指已消失。',
|
|
];
|
|
}
|
|
|
|
/** 广播事件名称。 */
|
|
public function broadcastAs(): string
|
|
{
|
|
return 'marriage.rejected';
|
|
}
|
|
}
|