2020-06-09 07:05:07 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2020-06-30 08:57:25 +00:00
|
|
|
use App\ResourceExtension;
|
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 ResourceExtensionController extends Controller
|
|
|
|
{
|
2020-06-30 07:21:21 +00:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->middleware([ "auth" ]);
|
2020-08-06 13:31:38 +00:00
|
|
|
$this->middleware([ "lang" ]);
|
2020-06-30 07:21:21 +00:00
|
|
|
|
|
|
|
$this->middleware([ "check.auth:resource.extension.list" ])->only("index");
|
|
|
|
$this->middleware([ "check.auth:resource.extension.show" ])->only("show");
|
|
|
|
$this->middleware([ "check.auth:resource.extension.create" ])->only("create", "store");
|
|
|
|
$this->middleware([ "check.auth:resource.extension.edit" ])->only("edit", "update");
|
|
|
|
$this->middleware([ "check.auth:resource.extension.delete" ])->only("delete");
|
|
|
|
}
|
|
|
|
|
2020-06-09 07:05:07 +00:00
|
|
|
/**
|
|
|
|
* Display a listing of the resource.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
2020-06-30 08:57:25 +00:00
|
|
|
public function index(Request $request)
|
2020-06-09 07:05:07 +00:00
|
|
|
{
|
2020-06-30 08:57:25 +00:00
|
|
|
$extensions = ResourceExtension::query()->paginate($request->input("limit", 20));
|
|
|
|
|
|
|
|
return Response::detect("resource-extensions.index", ["extension" => $extensions]);
|
2020-06-09 07:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the form for creating a new resource.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function create()
|
|
|
|
{
|
2020-06-30 08:57:25 +00:00
|
|
|
return Response::detect("resource-extensions.create");
|
2020-06-09 07:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Store a newly created resource in storage.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function store(Request $request)
|
|
|
|
{
|
2020-06-30 08:57:25 +00:00
|
|
|
$requestBody = $request->validate([
|
2020-06-30 09:27:39 +00:00
|
|
|
"extension" => "unique|required|max:255",
|
|
|
|
"description" => "required|max:255"
|
2020-06-30 08:57:25 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
$event = new ResourceExtension($requestBody);
|
|
|
|
|
|
|
|
$event->save();
|
|
|
|
|
|
|
|
return Response::detect("events.store");
|
2020-06-09 07:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the specified resource.
|
|
|
|
*
|
|
|
|
* @param int $id
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
2020-06-30 08:57:25 +00:00
|
|
|
public function show(ResourceExtension $id)
|
2020-06-09 07:05:07 +00:00
|
|
|
{
|
2020-06-30 08:57:25 +00:00
|
|
|
return Response::detect("resource-extensions.show", ["extension" => $id]);
|
2020-06-09 07:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the form for editing the specified resource.
|
|
|
|
*
|
|
|
|
* @param int $id
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function edit($id)
|
|
|
|
{
|
2020-06-30 08:57:25 +00:00
|
|
|
$extension = ResourceExtension::find($id);
|
|
|
|
return Response::detect("resource-extensions.edit", ["extension" => $extension]);
|
2020-06-09 07:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the specified resource in storage.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @param int $id
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function update(Request $request, $id)
|
|
|
|
{
|
2020-06-30 08:57:25 +00:00
|
|
|
$data = $request->all();
|
|
|
|
|
|
|
|
$extension = ResourceExtension::find($id);
|
|
|
|
$extension->update($data);
|
|
|
|
$extension->save();
|
|
|
|
|
|
|
|
return Response::detect("resource-extensions.update", [ "extension" => $extension]);
|
|
|
|
|
2020-06-09 07:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove the specified resource from storage.
|
|
|
|
*
|
|
|
|
* @param int $id
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function destroy($id)
|
|
|
|
{
|
2020-06-30 08:57:25 +00:00
|
|
|
$extension = ResourceExtension::find($id);
|
|
|
|
$extension->delete();
|
|
|
|
return redirect()->route("resource-extensions.index");
|
2020-06-09 07:05:07 +00:00
|
|
|
}
|
|
|
|
}
|