test tickets and messages notification
This commit is contained in:
parent
e099b88a80
commit
6ce69b6aaf
|
|
@ -16,8 +16,8 @@
|
|||
use App\Models\Ticket;
|
||||
use App\Models\User;
|
||||
use App\Notifications\ApplicationApproved;
|
||||
use App\Notifications\NewMessage;
|
||||
use App\Notifications\NewTicket;
|
||||
use App\Notifications\TicketMessage;
|
||||
use App\Notifications\TicketPosted;
|
||||
use Illuminate\Contracts\Database\Eloquent\Builder;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
|
|
@ -63,10 +63,10 @@ public function postMessage(MessageRequest $request)
|
|||
$message->save();
|
||||
$ticket = Ticket::find($request->ticket_id);
|
||||
if($ticket->last_sender == 'admin'){
|
||||
$users = User::with('permissions')->whereHas("permissions", function($q) {
|
||||
$users = User::with(['permissions' => function($q) {
|
||||
$q->whereIn("name", ["tickets"]);
|
||||
})->get();
|
||||
Notification::send($users, new NewMessage());
|
||||
}])->get();
|
||||
Notification::send($users, new TicketMessage());
|
||||
}
|
||||
$ticket['last_sender'] = 'client';
|
||||
$ticket->save();
|
||||
|
|
@ -90,10 +90,10 @@ public function postMessageAdmin(MessageRequest $request)
|
|||
$user = Client::find($ticket->client_id);
|
||||
if($user == null){
|
||||
$not_suspended_clients = Client::where('is_suspended', 0)->where('account_id', $request->account_id)->get();
|
||||
Notification::send($not_suspended_clients, new NewMessage());
|
||||
Notification::send($not_suspended_clients, new TicketMessage());
|
||||
}
|
||||
else{
|
||||
$user->notify(new NewTicket());
|
||||
$user->notify(new TicketMessage());
|
||||
}
|
||||
}
|
||||
$ticket['last_sender'] = 'admin';
|
||||
|
|
@ -127,18 +127,17 @@ public function postTicket(TicketRequest $request)
|
|||
$users = User::with(["permissions" => function($q) {
|
||||
$q->whereIn("name", ["tickets"]);
|
||||
}])->get();
|
||||
Notification::send($users, new NewTicket());
|
||||
Notification::send($users, new TicketPosted());
|
||||
return TicketResource::make($ticket);
|
||||
}
|
||||
|
||||
|
||||
public function createAppTicket(Request $request){
|
||||
$ticket = new Ticket($request->only('content', 'title','category_id', 'account_id', 'application_id'));
|
||||
$ticket['status_id'] = 1;
|
||||
$ticket['client_id'] = $request->account_id;
|
||||
$ticket->save();
|
||||
$not_suspended_clients = Client::where('is_suspended', 0)->where('account_id', $request->account_id)->get();
|
||||
Notification::send($not_suspended_clients, new NewTicket());
|
||||
Notification::send($not_suspended_clients, new TicketPosted());
|
||||
return redirect(route('chat',['ticket_id' => $ticket->id]));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class NewMessage extends Notification implements ShouldQueue
|
||||
class TicketMessage extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class NewTicket extends Notification implements ShouldQueue
|
||||
class TicketPosted extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
Loading…
Reference in New Issue