help desk notification ticketReceived
This commit is contained in:
parent
352fcb7dc3
commit
b41f11f7cc
|
|
@ -2,13 +2,17 @@
|
|||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\HelpTicketCommentRequest;
|
||||
use App\Models\HelpTicket;
|
||||
use App\Models\HelpTicketComment;
|
||||
use App\Notifications\TicketCommented;
|
||||
use Backpack\CRUD\app\Http\Controllers\CrudController;
|
||||
|
||||
// VALIDATION: change the requests to match your own file names if you need form validation
|
||||
use App\Http\Requests\HelpTicketRequest as StoreRequest;
|
||||
use App\Http\Requests\HelpTicketRequest as UpdateRequest;
|
||||
use Backpack\CRUD\CrudPanel;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
|
||||
/**
|
||||
* Class HelpTicletCrudController
|
||||
|
|
@ -97,4 +101,20 @@ class HelpTicketCrudController extends CrudController
|
|||
->with('entry',$entry)
|
||||
->with('crud',$this->crud);
|
||||
}
|
||||
|
||||
public function replayPost(HelpTicketCommentRequest $request, $ticket_id){
|
||||
$ticket = HelpTicket::findOrFail($ticket_id,['id','email','name']);
|
||||
|
||||
$comment = HelpTicketComment::create([
|
||||
'help_ticket_id' => $ticket_id,
|
||||
'text' => $request->text,
|
||||
'name' => auth()->user()->full_name,
|
||||
'user_id' => auth()->id()
|
||||
]);
|
||||
|
||||
Notification::route('mail', $ticket->email)
|
||||
->notify(new TicketCommented($comment));
|
||||
|
||||
return redirect()->route('ticket.replay',['id'=>$ticket_id]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Models\HelpTicketComment;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
class TicketCommented extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected $comment;
|
||||
|
||||
public function __construct(HelpTicketComment $comment)
|
||||
{
|
||||
$this->comment = $comment;
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
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.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($notifiable)
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -25,5 +25,5 @@ Route::group([
|
|||
CRUD::resource('helpTopic','HelpTopicCrudController');
|
||||
CRUD::resource('helpTicket','HelpTicketCrudController');
|
||||
Route::get('helpTicket/{id}/replay', 'HelpTicketCrudController@replay')->name('ticket.replay');
|
||||
Route::post('helpTicket/{id}/replay', 'HelpTicketCrudController@replay')->name('ticket.replay.post');
|
||||
Route::post('helpTicket/{id}/replay', 'HelpTicketCrudController@replayPost')->name('ticket.replay.post');
|
||||
}); // this should be the absolute last line of this file
|
||||
|
|
|
|||
Loading…
Reference in New Issue