123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace App\Http\Controllers\Admin;
- use Illuminate\Http\Request;
- use App\Http\Requests;
- use App\Http\Controllers\Controller;
- use App\User;
- use App\Models\Role;
- use App\Models\Permission;
- use Validator;
- class PermissionController extends Controller
- {
- public function index(){
- $data['title1'] = "Permission List";
- $data['title2'] = "Permission Add";
- $data['all_permissions'] = Permission::orderBy('name','ASC')->get();
- return view('admin.permission.index',$data);
- }
- public function store(Request $request){
- $this->validate($request,[
- 'name' => 'required|unique:permissions,name',
- 'display_name' => 'required',
- ]);
- $permission = new Permission();
- $permission->name = $request->name;
- $permission->display_name = $request->display_name;
- $permission->save();
- return back()->with('msg','Data Insert Successful !');
- }
- public function edit($id){
- $data['title'] = "Permission Edit";
- $data['permissions'] = Permission::find($id);
- return view('admin.permission.edit',$data);
- }
- public function update(Request $request,$id){
- $this->validate($request,[
- 'name' => 'required',
- 'display_name' => 'required',
- ]);
- $permission =Permission::find($id);
- $permission->name = $request->name;
- $permission->display_name = $request->display_name;
- $permission->update();
- return redirect('admin/permissions')->with('msg','Data Update Successful !');
- }
- public function destroy($id){
- Permission::whereId($id)->delete();
- return back()->with('msg','Data Delete Successful !');
- }
- }
|