90 lines
1.8 KiB
PHP
90 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use App\User;
|
|
use App\Permission;
|
|
use App\Http\Requests\StorePermission;
|
|
use App\Http\Requests\UpdatePermission;
|
|
|
|
class PermissionController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource
|
|
* @return Response
|
|
*/
|
|
public function index()
|
|
{
|
|
$response = Permission::all();
|
|
|
|
return response()->json([
|
|
'data' => $response
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage
|
|
* @param StorePermission $request
|
|
* @return Response
|
|
*/
|
|
public function store(StorePermission $request)
|
|
{
|
|
$validated = $request->validated();
|
|
|
|
$response = Permission::create($validated);
|
|
|
|
return response()->json([
|
|
'data' => $response
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Show the specified resource
|
|
* @param int $id
|
|
* @return Response
|
|
*/
|
|
public function show($id)
|
|
{
|
|
$response = Permission::findOrFail($id);
|
|
|
|
return response()->json([
|
|
'data' => $response
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage
|
|
* @param UpdatePermission $request
|
|
* @return Response
|
|
*/
|
|
public function update(UpdatePermission $request, $id)
|
|
{
|
|
$validated = $request->validated();
|
|
|
|
$permission = Permission::findOrFail($id);
|
|
|
|
$permission->update($validated);
|
|
|
|
return response()->json([
|
|
'data' => $permission
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage
|
|
* @param int $id
|
|
* @return Response
|
|
*/
|
|
public function destroy($id)
|
|
{
|
|
$permission = Permission::findOrFail($id);
|
|
|
|
$permission->delete();
|
|
|
|
return response()->json([
|
|
'message' => 'The data has been deleted'
|
|
]);
|
|
}
|
|
}
|