firstcommit
This commit is contained in:
92
Modules/User/app/Http/Controllers/PermissionController.php
Normal file
92
Modules/User/app/Http/Controllers/PermissionController.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\User\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\User\Repositories\PermissionInterface;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
|
||||
class PermissionController extends Controller
|
||||
{
|
||||
|
||||
private $permissionRepository;
|
||||
public function __construct(PermissionInterface $permissionRepository)
|
||||
{
|
||||
$this->permissionRepository = $permissionRepository;
|
||||
}
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$data['permissionLists'] = $this->permissionRepository->findAll();
|
||||
$data['title'] = 'Permission Lists';
|
||||
|
||||
return view('user::permissions.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(string $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit(Permission $permission)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, Permission $permission)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy(Permission $permission)
|
||||
{
|
||||
$permission->delete();
|
||||
toastr()->success('Permission has been deleted!');
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function generatePermissionFromRoutes()
|
||||
{
|
||||
try {
|
||||
$this->permissionRepository->generatePermissionFromRoutes();
|
||||
toastr()->success('Permission generated successfully!');
|
||||
} catch (\Throwable $th) {
|
||||
toastr()->error($th->getMessage());
|
||||
|
||||
}
|
||||
|
||||
return to_route('permission.index');
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user