27 lines
719 B
PHP
27 lines
719 B
PHP
<?php
|
|
|
|
namespace App\Actions;
|
|
|
|
use App\Models\Broker;
|
|
use App\Models\Customer;
|
|
use App\Models\Deal;
|
|
use App\Models\Follow;
|
|
use App\Notifications\NewDealNotification;
|
|
|
|
final readonly class SendDealCreatedNotificationCustomerAction
|
|
{
|
|
public function execute(Deal $deal): void
|
|
{
|
|
/**
|
|
* @var Broker $broker
|
|
*/
|
|
$broker = $deal->broker->type;
|
|
$followers = $broker->followers()->with('user')->get();
|
|
$followers->map(function (Customer $customer) use ($deal) {
|
|
\Log::info('dump', [$customer]);
|
|
\Log::info("Sending notification to {$customer->user->name}");
|
|
$customer->user->notify(new NewDealNotification($deal));
|
|
});
|
|
}
|
|
}
|