-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFeedbackController.php
42 lines (34 loc) · 1002 Bytes
/
FeedbackController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
namespace App\Http\Controllers;
use App\Feedback;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use DB;
class FeedbackController extends Controller
{
public function getFeedback()
{
$feedbacks=Feedback::all();
return view('feedback',['feedbacks'=>$feedbacks]);
}
public function viewFeedback()
{
$feedbacks=Feedback::orderBy('created_at','desc')->get();
return view('viewmessages',['feedbacks'=>$feedbacks]);
}
public function feedbackCreateFeedback(Request $request)
{
$this->validate($request,[
'message'=>'required|max:1000'
]);
$feedback=new Feedback();
$feedback->message=$request['message'];
$feedback->read=0;
$message='There was an error sending your feedback';
if($request->user()->feedbacks()->save($feedback)){
$message='Feedback sucessfully submitted!';
};
return redirect()->route('dashboard')->with(['message'=>$message]);
}
}