Basic
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Models\User;
class UserController extends Controller
{
public function show($id)
{
return view('user.profile', [
'user' => User::findOrFail($id)
]);
}
}
Define a route for this controller method:
use App\Http\Controllers\UserController;
Route::get('/user/{id}', [UserController::class, 'show']);
Comments