<?phpnamespaceApp\Http\Controllers\Admin;useApp\Http\Controllers\Controller;useApp\Models\Permission;useIlluminate\Http\Request;classPermissionControllerextendsController{publicfunction__construct() {$this->middleware('can:permission list', ['only'=> ['index','show']]);$this->middleware('can:permission create', ['only'=> ['create','store']]);$this->middleware('can:permission edit', ['only'=> ['edit','update']]);$this->middleware('can:permission delete', ['only'=> ['destroy']]); }/** * Display a listing of the resource. */publicfunctionindex() { $permissions =Permission::latest()->paginate(5);returnview('admin.permission.index', compact('permissions'))->with('i', (request()->input('page',1)-1) *5); }/** * Show the form for creating a new resource. */publicfunctioncreate() {returnview('admin.permission.create'); }/** * Store a newly created resource in storage. */publicfunctionstore(Request $request) { $request->validate(['name'=>'required|string|max:255|unique:'.config('permission.table_names.permissions','permissions').',name']);Permission::create(['name'=> $request->name,'guard_name'=>'web']);returnredirect()->route('permission.index')->with('message','Permission created successfully.'); }/** * Display the specified resource. */publicfunctionshow(Permission $permission) {// }/** * Show the form for editing the specified resource. */publicfunctionedit(Permission $permission) {returnview('admin.permission.edit', compact('permission')); }/** * Update the specified resource in storage. */publicfunctionupdate(Request $request,Permission $permission) { $request->validate(['name'=>'required|string|max:255|unique:'.config('permission.table_names.permissions','permissions').',name,'. $permission->id,]); $permission->update(['name'=> $request->name,'guard_name'=>'web']);returnredirect()->route('permission.index')->with('message','Permission updated successfully.'); }/** * Remove the specified resource from storage. */publicfunctiondestroy(Permission $permission) { $permission->delete();returnredirect()->route('permission.index')->with('message','Permission deleted successfully'); }}
C:\xampp82\htdocs\lva1\routes\web.php
<?phpuseApp\Http\Controllers\Admin\PermissionController;useApp\Http\Controllers\Admin\RoleController;useApp\Http\Controllers\Admin\UserController;useApp\Http\Controllers\Admin\ProductController;useIlluminate\Support\Facades\Auth;useIlluminate\Support\Facades\Route;/*|--------------------------------------------------------------------------| Web Routes|--------------------------------------------------------------------------|| Here is where you can register web routes for your application. These| routes are loaded by the RouteServiceProvider and all of them will| be assigned to the "web" middleware group. Make something great!|*/Route::get('/',function () {returnview('welcome');});Auth::routes();Route::get('/home', [App\Http\Controllers\HomeController::class,'index'])->name('home');Route::get('/dashboard',function () {returnview('dashboard');})->middleware(['auth'])->name('dashboard');Route::prefix('admin')->namespace('App\Http\Controllers\Admin')->middleware(['auth'])->group(function () {Route::resource('permission',PermissionController::class);Route::resource('role',RoleController::class);Route::resource('user',UserController::class);Route::get('edit-account-info', [UserController::class,'profileInformation'])->name('admin.profile.info');Route::post('edit-account-info', [UserController::class,'profileInformationStore'])->name('admin.profile.info.store');Route::post('change-password', [UserController::class,'changePasswordStore'])->name('admin.profile.password.store');Route::resource('product',ProductController::class);});