這時候我已經網址這樣 http://Blog/user/profile/51 和我與他們ID的用戶登錄= 51,但如果我改變這個ID來50它顯示用戶的ID爲50的數據的形式我想停止這個,我可以如何保護幫助。 哪能的othere我如何可以被其他用戶保護個人資料的形式更新laravel 5.3
public function profile($id, Request $request)
{
***if($id == Auth::user()->id){
Now Check get or post method
}else{
return ('Out');
}***
$method = $request->method();
if ($request->isMethod('get')) {
$user = User::findOrFail($id);
$users = DB::table('users')->select('id', 'name')->get();
$user_fields = DB::table('users')->where('id', $user->id)->get();
$page_data = [
'title' => 'Edit User Account',
'action' => 'edit'
];
return view('user.profile')->with(compact('user', 'page_data', 'users'));
}else{
$this->validate($request, [
'name' => 'required|max:255',
]);
$user = User::findOrFail($id);
$input = $request->all();
$user->fill([
'name' => $request->input('name'),
'password' => $request->password ? bcrypt($request->input('password')) : $user->password,
'time_zone' => $request->input('time_zone'),
'address_line_1' => $request->input('address_line_1'),
'address_line_2' => $request->input('address_line_2'),
])->save();
session()->flash('msg',trans('successfully Updated.'));
}
執行前檢查這個條件我有想法,我可以檢查auth用戶ID等於這個ID,但不知道如何實現我在這裏打磨網址爲
<form action="/user/profile/{{$user->id}}" method="POST">
我在這裏取auth用戶id作爲
<a href="{{ route('user.profile', ['id' => Auth::user()->id ]) }}">
路線如下
Route::any('/user/profile/{id}', ['as' => 'user.profile', 'uses' => '[email protected]']);
現在,我怎麼表演形式,以用戶是其相關的形式或不 感謝
您爲什麼要向用戶51顯示用戶50的表單。當用戶51嘗試查看用戶50的用戶時,顯示404。 –