我的配置文件控制器中有方法可以检索用户详细信息。
路线如下:
Route::get('show-profile/{slug}', 'ProfileController@show')-
>name('profile.show')->where('username', '[\w\d\-\_]+');
,方法是:
public function show($slug)
{
$profile = User::where('username', $slug)->first();
return response()->json([
'profile' => $profile,
'title' => 'My Profile'
]);
// return view('dashboard.profile-show', ['profile' => $profile, 'title' => 'My Profile',]);
}
我的挑战是我不想将它传递给视图刀片,相反,我想使用vue.js并获得json响应。
感谢您的帮助。