2020-04-30 08:34:51 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
|
|
|
2020-04-30 12:39:58 +00:00
|
|
|
use App\Http\Requests\HelpTicketCommentRequest;
|
|
|
|
|
use App\Http\Requests\HelpTicketRequest;
|
|
|
|
|
use App\Models\HelpTicket;
|
|
|
|
|
use App\Models\HelpTicketComment;
|
2020-04-30 10:19:16 +00:00
|
|
|
use App\Models\HelpTopic;
|
2020-05-01 10:54:03 +00:00
|
|
|
use Illuminate\Support\Facades\Log;
|
2020-04-30 08:34:51 +00:00
|
|
|
|
|
|
|
|
class HelpDeskController extends Controller
|
|
|
|
|
{
|
|
|
|
|
|
2020-04-30 12:39:58 +00:00
|
|
|
public function show($code){
|
2020-04-30 08:34:51 +00:00
|
|
|
|
2020-04-30 12:39:58 +00:00
|
|
|
$ticket = HelpTicket::with('comments')
|
|
|
|
|
->where('code',$code)
|
|
|
|
|
->first();
|
|
|
|
|
if(!$ticket)
|
|
|
|
|
abort(404);
|
|
|
|
|
|
|
|
|
|
return $this->render('Pages.HelpDeskTicket',['ticket' => $ticket]);
|
2020-04-30 08:34:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Show the form for creating the help desk ticket
|
|
|
|
|
*/
|
|
|
|
|
public function create(){
|
|
|
|
|
|
2020-04-30 10:19:16 +00:00
|
|
|
return $this->render('Pages.HelpDeskCreateForm');
|
2020-04-30 08:34:51 +00:00
|
|
|
}
|
|
|
|
|
|
2020-04-30 12:39:58 +00:00
|
|
|
public function store(HelpTicketRequest $request){
|
2020-05-04 13:32:02 +00:00
|
|
|
|
2020-05-05 08:11:38 +00:00
|
|
|
try{
|
2020-05-05 07:06:17 +00:00
|
|
|
|
2020-05-01 10:54:03 +00:00
|
|
|
$ticekt = HelpTicket::create([
|
|
|
|
|
'name' => $request->get('name'),
|
|
|
|
|
'email' => $request->get('email'),
|
|
|
|
|
'text' => $request->get('text'),
|
|
|
|
|
'phone' => $request->get('phone'),
|
|
|
|
|
'subject' => $request->get('subject'),
|
|
|
|
|
'ticket_category_id' => $request->get('topic'),
|
2020-05-05 07:06:17 +00:00
|
|
|
'attachment' => $request->file('attachment')
|
2020-05-01 10:54:03 +00:00
|
|
|
]);
|
2020-05-05 08:11:38 +00:00
|
|
|
//todo fire event notify admin by mail, attachment
|
|
|
|
|
return redirect()->route('help.show',['code' => $ticekt->code]);
|
|
|
|
|
}
|
|
|
|
|
catch (\Exception $exception){
|
|
|
|
|
Log::error($exception);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-04-30 08:34:51 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-30 12:39:58 +00:00
|
|
|
public function comment(HelpTicketCommentRequest $request,$code){
|
|
|
|
|
|
|
|
|
|
$ticket = HelpTicket::select('id')
|
|
|
|
|
->where('code',$code)
|
|
|
|
|
->first();
|
|
|
|
|
|
|
|
|
|
if(!$ticket)
|
|
|
|
|
abort(404);
|
|
|
|
|
|
|
|
|
|
$comment = HelpTicketComment::create([
|
|
|
|
|
'text' => $request->text,
|
|
|
|
|
'help_ticket_id' => $ticket->id
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$ticket->update(['status' => 'pending']) ;
|
|
|
|
|
|
2020-05-01 10:54:03 +00:00
|
|
|
if($request->has('attachment')){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-30 12:39:58 +00:00
|
|
|
//todo notify, attachment
|
|
|
|
|
|
|
|
|
|
return redirect()->route('help.show',['code' => $code]);
|
2020-04-30 08:34:51 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|