добавлен лог по сущностям контактов и договоров
This commit is contained in:
parent
93a09f63ad
commit
b9dc42166e
@ -9,6 +9,8 @@
|
|||||||
use App\Models\Deal\DealStatus;
|
use App\Models\Deal\DealStatus;
|
||||||
use App\Notifications\UniqueContact;
|
use App\Notifications\UniqueContact;
|
||||||
use App\Notifications\NotUniqueContact;
|
use App\Notifications\NotUniqueContact;
|
||||||
|
use App\Notifications\Deal\DealUnique;
|
||||||
|
use App\Notifications\Deal\DealNotUnique;
|
||||||
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
@ -42,11 +44,13 @@ public function confirm(Deal $deal, Request $request)
|
|||||||
{
|
{
|
||||||
$deal->status = DealStatus::UNIQUE;
|
$deal->status = DealStatus::UNIQUE;
|
||||||
$agent->user->notify(new UniqueContact($deal));
|
$agent->user->notify(new UniqueContact($deal));
|
||||||
|
$deal->notify(new DealUnique());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$deal->status = DealStatus::NOT_UNIQUE;
|
$deal->status = DealStatus::NOT_UNIQUE;
|
||||||
$agent->user->notify(new NotUniqueContact($deal));
|
$agent->user->notify(new NotUniqueContact($deal));
|
||||||
|
$deal->notify(new DealNotUnique());
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::build([
|
Log::build([
|
||||||
|
|||||||
@ -8,12 +8,14 @@
|
|||||||
use App\Notifications\UniqueContact;
|
use App\Notifications\UniqueContact;
|
||||||
use App\Notifications\NotUniqueContact;
|
use App\Notifications\NotUniqueContact;
|
||||||
use App\Notifications\ContractUpdated;
|
use App\Notifications\ContractUpdated;
|
||||||
|
use App\Notifications\Deal\DealCreated;
|
||||||
|
|
||||||
|
|
||||||
class NotificationProbeController extends Controller
|
class NotificationProbeController extends Controller
|
||||||
{
|
{
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
auth()->user()->notify(new ContractUpdated(Deal::find(4)->contract));
|
Deal::find(4)->notify(new DealCreated());
|
||||||
echo auth()->user()->unreadNotifications->count() . '<br>';
|
echo auth()->user()->unreadNotifications->count() . '<br>';
|
||||||
die(auth()->user()->notifications);
|
die(auth()->user()->notifications);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,9 +8,11 @@
|
|||||||
use App\Models\User\UserRole;
|
use App\Models\User\UserRole;
|
||||||
use App\Models\User\Role;
|
use App\Models\User\Role;
|
||||||
|
|
||||||
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
|
||||||
class Deal extends Model
|
class Deal extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory, Notifiable;
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'client_id',
|
'client_id',
|
||||||
'complex_id',
|
'complex_id',
|
||||||
@ -45,13 +47,16 @@ protected static function booted(): void
|
|||||||
'user_id' => $deal->client_id,
|
'user_id' => $deal->client_id,
|
||||||
'role_id' => Role::CLIENT
|
'role_id' => Role::CLIENT
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
//$this->notify();
|
||||||
});
|
});
|
||||||
|
|
||||||
static::deleted(function (Deal $deal)
|
static::deleted(function (Deal $deal)
|
||||||
{
|
{
|
||||||
UserRole::where([
|
/*UserRole::where([
|
||||||
'user_id' => $deal->client_id,
|
'user_id' => $deal->client_id,
|
||||||
'role_id' => Role::CLIENT
|
'role_id' => Role::CLIENT
|
||||||
])->delete();
|
])->delete();*/
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
56
app/Notifications/Deal/ContractUpdated.php
Normal file
56
app/Notifications/Deal/ContractUpdated.php
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Notifications\Deal;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
use Illuminate\Notifications\Notification;
|
||||||
|
|
||||||
|
use App\Models\Deal\Deal;
|
||||||
|
use App\Models\Deal\DealStatus;
|
||||||
|
|
||||||
|
class ContractUpdated extends Notification
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
private $deal;
|
||||||
|
/**
|
||||||
|
* Create a new notification instance.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the notification's delivery channels.
|
||||||
|
*
|
||||||
|
* @return array<int, string>
|
||||||
|
*/
|
||||||
|
public function via(object $notifiable): array
|
||||||
|
{
|
||||||
|
return ['database'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the mail representation of the notification.
|
||||||
|
*/
|
||||||
|
public function toMail(object $notifiable): MailMessage
|
||||||
|
{
|
||||||
|
return (new MailMessage)
|
||||||
|
->line('The introduction to the notification.')
|
||||||
|
->action('Notification Action', url('/'))
|
||||||
|
->line('Thank you for using our application!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the array representation of the notification.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function toArray(object $notifiable): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'text' => __('notifications.' . get_class($this))
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
56
app/Notifications/Deal/DealCreated.php
Normal file
56
app/Notifications/Deal/DealCreated.php
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Notifications\Deal;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
use Illuminate\Notifications\Notification;
|
||||||
|
|
||||||
|
use App\Models\Deal\Deal;
|
||||||
|
use App\Models\Deal\DealStatus;
|
||||||
|
|
||||||
|
class DealCreated extends Notification
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
private $deal;
|
||||||
|
/**
|
||||||
|
* Create a new notification instance.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the notification's delivery channels.
|
||||||
|
*
|
||||||
|
* @return array<int, string>
|
||||||
|
*/
|
||||||
|
public function via(object $notifiable): array
|
||||||
|
{
|
||||||
|
return ['database'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the mail representation of the notification.
|
||||||
|
*/
|
||||||
|
public function toMail(object $notifiable): MailMessage
|
||||||
|
{
|
||||||
|
return (new MailMessage)
|
||||||
|
->line('The introduction to the notification.')
|
||||||
|
->action('Notification Action', url('/'))
|
||||||
|
->line('Thank you for using our application!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the array representation of the notification.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function toArray(object $notifiable): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'text' => __('notifications.' . get_class($this))
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
55
app/Notifications/Deal/DealNotUnique.php
Normal file
55
app/Notifications/Deal/DealNotUnique.php
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Notifications\Deal;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
use Illuminate\Notifications\Notification;
|
||||||
|
|
||||||
|
use App\Models\Deal\Deal;
|
||||||
|
use App\Models\Deal\DealStatus;
|
||||||
|
|
||||||
|
class DealNotUnique extends Notification
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
/**
|
||||||
|
* Create a new notification instance.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the notification's delivery channels.
|
||||||
|
*
|
||||||
|
* @return array<int, string>
|
||||||
|
*/
|
||||||
|
public function via(object $notifiable): array
|
||||||
|
{
|
||||||
|
return ['database'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the mail representation of the notification.
|
||||||
|
*/
|
||||||
|
public function toMail(object $notifiable): MailMessage
|
||||||
|
{
|
||||||
|
return (new MailMessage)
|
||||||
|
->line('The introduction to the notification.')
|
||||||
|
->action('Notification Action', url('/'))
|
||||||
|
->line('Thank you for using our application!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the array representation of the notification.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function toArray(object $notifiable): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'text' => __('notifications.' . get_class($this))
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
56
app/Notifications/Deal/DealUnique.php
Normal file
56
app/Notifications/Deal/DealUnique.php
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Notifications\Deal;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
use Illuminate\Notifications\Notification;
|
||||||
|
|
||||||
|
use App\Models\Deal\Deal;
|
||||||
|
use App\Models\Deal\DealStatus;
|
||||||
|
|
||||||
|
class DealCreated extends Notification
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
private $deal;
|
||||||
|
/**
|
||||||
|
* Create a new notification instance.
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the notification's delivery channels.
|
||||||
|
*
|
||||||
|
* @return array<int, string>
|
||||||
|
*/
|
||||||
|
public function via(object $notifiable): array
|
||||||
|
{
|
||||||
|
return ['database'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the mail representation of the notification.
|
||||||
|
*/
|
||||||
|
public function toMail(object $notifiable): MailMessage
|
||||||
|
{
|
||||||
|
return (new MailMessage)
|
||||||
|
->line('The introduction to the notification.')
|
||||||
|
->action('Notification Action', url('/'))
|
||||||
|
->line('Thank you for using our application!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the array representation of the notification.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function toArray(object $notifiable): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'text' => __('notifications.' . get_class($this))
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -16,4 +16,10 @@
|
|||||||
'App\Notifications\UniqueContact' => 'Контакт :contact был проверен, уникальность подтверждена',
|
'App\Notifications\UniqueContact' => 'Контакт :contact был проверен, уникальность подтверждена',
|
||||||
'App\Notifications\NotUniqueContact' => 'Контакт :contact был проверен и является не уникальным',
|
'App\Notifications\NotUniqueContact' => 'Контакт :contact был проверен и является не уникальным',
|
||||||
'App\Notifications\ContractUpdated' => 'Информация о договоре для контакта ":contact" обновлен',
|
'App\Notifications\ContractUpdated' => 'Информация о договоре для контакта ":contact" обновлен',
|
||||||
|
|
||||||
|
'App\Notifications\Deal\DealCreated' => 'Контакт создан',
|
||||||
|
'App\Notifications\Deal\DealUnique' => 'Стутус контакта изменен на "уникальный"',
|
||||||
|
'App\Notifications\Deal\DealNotUnique' => 'Стутус контакта изменен на "не уникальный"',
|
||||||
|
'App\Notifications\Deal\ContractUpdated' => 'Информация о договоре обновлена',
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user