首页 > 代码库 > 最简单的增删改查
最简单的增删改查
<?phpnamespace App\Http\Controllers\Admin;use App\Models\AdminUser;use App\Http\Requests\Admin\AdminuserRequest;class AdminusersController extends Controller{ public function getIndex() { $users = AdminUser::where(‘role‘, ‘adminer‘) ->where(‘id‘, ‘!=‘, 1) ->paginate(8); return view(‘admin.admin_users.index‘, compact(‘users‘)); } public function getData(AdminUser $users) { $users->mergeAttributesOld(); return view(‘admin.admin_users.edit‘, compact(‘users‘)); } public function getEdit($id) { $users = AdminUser::findOrFail($id); return view(‘admin.admin_users.edit‘, compact(‘users‘)); } public function postStore(AdminuserRequest $request) { $data = $request->getData(); $data[‘role‘] = ‘adminer‘; AdminUser::create($data); return redirect()->action(‘Admin\AdminusersController@getIndex‘); } public function postUpdate(AdminuserRequest $request, $id) { $data = $request->getData(); $users = AdminUser::findOrFail($id); $users->update($data); return redirect()->action(‘Admin\AdminusersController@getIndex‘); } public function deleteAdminUser($id) { AdminUser::findOrFail($id)->delete(); return redirect()->action(‘Admin\AdminusersController@getIndex‘); }}
最简单的增删改查
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。