Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 26 |
| PermissionController | |
0.00% |
0 / 1 |
|
0.00% |
0 / 7 |
56 | |
0.00% |
0 / 26 |
| index | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 4 |
|||
| create | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 4 |
|||
| store | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 4 |
|||
| show | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| edit | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 6 |
|||
| update | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 4 |
|||
| destroy | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 3 |
|||
| <?php | |
| namespace App\Http\Controllers\Admin; | |
| use Illuminate\Http\Request; | |
| use App\Http\Controllers\Controller; | |
| use App\Authorizable; | |
| use Spatie\Permission\Models\Role; | |
| use Spatie\Permission\Models\Permission; | |
| use Illuminate\Support\Facades\Validator; | |
| use App\Http\Controllers\Admin\flash; | |
| use Session; | |
| class PermissionController extends Controller | |
| { | |
| /** | |
| * Display a listing of the resource. | |
| * | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function index() | |
| { | |
| $home= 'Home'; | |
| $title = '/Setup/Permission'; | |
| $permissions = Permission::all(); | |
| return view('administrationForms.Permission.PermissionTable', compact('permissions','home','title')); | |
| } | |
| /** | |
| * Show the form for creating a new resource. | |
| * | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function create() | |
| { | |
| $home= 'Home'; | |
| $title = '/Setup/Create-Permission'; | |
| $createpermissions = Permission::get()->groupBy(['module_name','sub_heading_name']); | |
| // /die(); | |
| return view('administrationForms.Permission.PermissionForm', compact( 'createpermissions','home','title')); | |
| } | |
| /** | |
| * Store a newly created resource in storage. | |
| * | |
| * @param \Illuminate\Http\Request $request | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function store(Request $request) | |
| { | |
| $this->validate($request, ['name' => 'required|unique:permissions']); | |
| $permission = Permission::create($request->only('name')); | |
| Session::flash('success', 'Add Permission successful!'); | |
| return redirect()->route('permission.create'); | |
| } | |
| /** | |
| * Display the specified resource. | |
| * | |
| * @param int $id | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function show($id) | |
| { | |
| // | |
| } | |
| /** | |
| * Show the form for editing the specified resource. | |
| * | |
| * @param int $id | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function edit(Request $request, $id) | |
| { | |
| $home= 'Home'; | |
| $title = '/Setup/Edit/Permission'; | |
| $permission = Permission::where('id', $id)->first(); | |
| $permissions= Permission::get(); | |
| Session::flash('warning', 'Edit Permission'); | |
| return view('administrationForms.Permission.PermissionForm', compact('permissions','home','title','assignedPermissions'))->with('role',Role::find($id)); | |
| } | |
| /** | |
| * Update the specified resource in storage. | |
| * | |
| * @param \Illuminate\Http\Request $request | |
| * @param int $id | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function update(Request $request, $id) | |
| { | |
| Permission::where('id',$id)->update($request->only('name')); | |
| $permission = Permission::findByName($request->input('name')); | |
| Session::flash('success', 'Permission Updated Successfully!'); | |
| return redirect()->route('permission.index'); | |
| } | |
| /** | |
| * Remove the specified resource from storage. | |
| * | |
| * @param int $id | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function destroy($id) | |
| { | |
| $permission = Permission::find($id); | |
| $permission->delete(); | |
| return redirect()->route('permission.index')->with('success','Permission Deleted Successfully'); | |
| } | |
| } |