Attendize/app/Http/Controllers/HelpDeskController.php

84 lines
2.0 KiB
PHP
Raw Normal View History

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-01 10:54:03 +00:00
//
// try{
$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'),
'attachment' => $request->get('attachment')
]);
// }
// catch (\Exception $exception){
// Log::error($exception);
// }
2020-04-30 12:39:58 +00:00
//todo fire event notify admin by mail, attachment
2020-04-30 08:34:51 +00:00
2020-04-30 12:39:58 +00:00
return redirect()->route('help.show',['code' => $ticekt->code]);
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
}
}