Route::group 中用于路由目的的默认控制器?

Default controller in Route::group for routing purposes?

我想按 id 显示一些用户数据。简单的。

user/{id} -> 从控制器的方法中获取数据。

我有这个:

Route::group(['prefix' => 'user/{id}', 'where' => ['id' => '[0-9]+']], function() {
       Route::get('delete', 'UserController@delete')->name('admin.access.user.delete-permanently');
       Route::get('restore', 'UserController@restore')->name('admin.access.user.restore');
       Route::get('mark/{status}', 'UserController@mark')->name('admin.access.user.mark')->where(['status' => '[0,1]']);
       Route::get('password/change', 'UserController@changePassword')->name('admin.access.user.change-password');
       Route::post('password/change', 'UserController@updatePassword')->name('admin.access.user.change-password');
});

如何访问 user/{id} 的默认方法?

您可以在控制器中执行此操作

<?php

namespace App\Http\Controllers;

use App\User;
use App\Http\Controllers\Controller;

class UserController extends Controller
{
    /**
     * Show the profile for the given user.
     *
     * @param  int  $id
     * @return Response
     */
    public function show($id)
    {
        //Fetch and send the user to the "profile" blade file in the folder "resources/views/user"
        return view('user.profile', ['user' => User::findOrFail($id)]);
    }

    public function changePassword($id)
    {
        $user = User::findOrFail($id);
        return $user->update(
             'password' => bcrypt(123456)
        );
    }
}