2020-06-09 07:05:07 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2020-06-25 09:19:51 +00:00
|
|
|
use App\Feedback;
|
2020-06-09 07:05:07 +00:00
|
|
|
use Illuminate\Http\Request;
|
2020-06-24 06:23:15 +00:00
|
|
|
use Illuminate\Http\Response;
|
|
|
|
|
2020-06-09 07:05:07 +00:00
|
|
|
|
|
|
|
class FeedbackController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Display a listing of the resource.
|
|
|
|
*
|
2020-06-25 09:19:51 +00:00
|
|
|
* @param Request $request
|
|
|
|
* @return Response
|
2020-06-09 07:05:07 +00:00
|
|
|
*/
|
2020-06-25 09:19:51 +00:00
|
|
|
public function index(Request $request)
|
2020-06-09 07:05:07 +00:00
|
|
|
{
|
2020-06-25 09:19:51 +00:00
|
|
|
$feedback = Feedback::query()->paginate($request->input("limit", 20));
|
|
|
|
|
|
|
|
return Response::detect("feedback.index", [ "feedback" => $feedback ]);
|
2020-06-09 07:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the form for creating a new resource.
|
|
|
|
*
|
2020-06-25 09:19:51 +00:00
|
|
|
* @return Response
|
2020-06-09 07:05:07 +00:00
|
|
|
*/
|
|
|
|
public function create()
|
|
|
|
{
|
2020-06-25 09:19:51 +00:00
|
|
|
return Response::detect("feedback.create");
|
2020-06-09 07:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Store a newly created resource in storage.
|
|
|
|
*
|
2020-06-25 09:19:51 +00:00
|
|
|
* @param Request $request
|
|
|
|
* @return Response
|
2020-06-09 07:05:07 +00:00
|
|
|
*/
|
|
|
|
public function store(Request $request)
|
|
|
|
{
|
2020-06-25 09:19:51 +00:00
|
|
|
$requestBody = $request->validate([
|
|
|
|
"name" => "required|max:255",
|
|
|
|
"link" => "required|max:255"
|
|
|
|
]);
|
|
|
|
|
|
|
|
$feedback = new Feedback($requestBody);
|
|
|
|
$feedback->save();
|
|
|
|
|
|
|
|
return Response::detect("feedback.store");
|
2020-06-09 07:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the specified resource.
|
|
|
|
*
|
|
|
|
* @param int $id
|
2020-06-25 09:19:51 +00:00
|
|
|
* @return Response
|
2020-06-09 07:05:07 +00:00
|
|
|
*/
|
|
|
|
public function show($id)
|
|
|
|
{
|
2020-06-25 09:19:51 +00:00
|
|
|
return Response::detect("feedback.show", [ "feedback" => $id]);
|
2020-06-09 07:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the form for editing the specified resource.
|
|
|
|
*
|
|
|
|
* @param int $id
|
2020-06-25 09:19:51 +00:00
|
|
|
* @return Response
|
2020-06-09 07:05:07 +00:00
|
|
|
*/
|
|
|
|
public function edit($id)
|
|
|
|
{
|
2020-06-25 10:40:26 +00:00
|
|
|
$feedback = Feedback::find($id);
|
|
|
|
|
|
|
|
return Response::detect("feedbacks.edit", [
|
|
|
|
"feedback" => $feedback
|
|
|
|
]);
|
2020-06-09 07:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the specified resource in storage.
|
|
|
|
*
|
2020-06-25 09:19:51 +00:00
|
|
|
* @param Request $request
|
|
|
|
* @param int $id
|
|
|
|
* @return void
|
2020-06-09 07:05:07 +00:00
|
|
|
*/
|
|
|
|
public function update(Request $request, $id)
|
|
|
|
{
|
2020-06-25 10:40:26 +00:00
|
|
|
$data = $request->validate([
|
|
|
|
"time" => "required"
|
|
|
|
]);
|
|
|
|
|
|
|
|
$feedback = Feedback::find($id);
|
|
|
|
|
|
|
|
$feedback->update($data);
|
|
|
|
|
|
|
|
$feedback->save();
|
|
|
|
|
|
|
|
return Response::detect("feedbacks.edit", [
|
|
|
|
"feedback" => $feedback
|
|
|
|
]);
|
2020-06-09 07:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove the specified resource from storage.
|
|
|
|
*
|
|
|
|
* @param int $id
|
2020-06-25 09:19:51 +00:00
|
|
|
* @return Response
|
2020-06-09 07:05:07 +00:00
|
|
|
*/
|
|
|
|
public function destroy($id)
|
|
|
|
{
|
2020-06-25 10:40:26 +00:00
|
|
|
$feedback = Feedback::find($id);
|
|
|
|
$feedback->delete();
|
|
|
|
|
|
|
|
return Response::detect("feedbacks.destroy");
|
2020-06-09 07:05:07 +00:00
|
|
|
}
|
|
|
|
}
|