Let me try to explain a bit. Let's say you have 2 user with id 1 and 2, next you have your edit user profile function
class UsersController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function edit($id)
{
// this condition you need to add.
if(auth()->user()->id != $id)
{
return abort(403, 'Unauthorized action.');
}
$user = User::findOrFail($id);
return view('users.edit', compact('user'));
}
}
Now when user with ID 1 will access site.com/users/1/edit he will be able to edit, but when he will access site.com/users/2/edit he will get 403, Unauthorized action, and you don't need anymore slugs, hashed and so one. Other alternatives are middlewares or policies