title: User::where(user->id==$profile->id); get profile that is equal to user in controller
body: <p>If you set relation ships between the <code>User.php return $this-&gt;belongsTo('App\User');</code> and <code>Profile.php return $this-&gt;hasOne('App\Profile', 'user_id', 'id');</code> how can u get a corresponding user to the profile when you only get the Profile variables. <code>public function update(Request $request, Profile $profile)</code></p>
  
  <p>i was thinking of something like this <code>User::where(user-&gt;id==$profile-&gt;id);</code> but its not working how would can you do it?</p>
  
  <p>mine hole function: </p>
  
  <pre><code>if(\Auth::check()) {
  
          if(\Auth::user()-&gt;type == 'admin'){
  
              $validated = $request-&gt;validate([
  
                  'username' =&gt; 'required',
  
                  'email' =&gt; 'required|email',
  
                  'firstname' =&gt; 'required',
  
                  'lastname' =&gt; 'required',
  
                  'age' =&gt; 'required|numeric|max:150',
  
                  'birthdate' =&gt; 'required|numeric',
  
                  'bio' =&gt; 'required|min:30',
  
                  'select_file'  =&gt; 'image|mimes:jpg,png,gif,jpeg|max:2048'
  
              ]);
  
              $image = $request-&gt;file('select_file');
              $new_name = rand() . '.' . $image-&gt;getClientOriginalExtension();
              $image-&gt;move(public_path('images'), $new_name);
  
              $profile-&gt;username      = $validated['username'];
              $profile-&gt;email         = $validated['email'];
              $profile-&gt;firstname     = $validated['firstname'];
              $profile-&gt;lastname      = $validated['lastname'];
              $profile-&gt;age           = $validated['age'];
              $profile-&gt;birthdate     = $validated['birthdate'];
              $profile-&gt;bio           = $validated['bio'];
              $profile-&gt;image_path    = $new_name;
              $profile-&gt;update();
  
              $user                   = User::where(user-&gt;id==$profile-&gt;id);
              $user-&gt;name             = $validated['username'];
              $user-&gt;email            = $validated['email'];
              $user-&gt;update();
  
              return redirect()
                  -&gt;route('admin')
                  -&gt;with('succes', 'Profile updated succesfully');
          } else {
  
              return redirect()
                  -&gt;route('admin')
                  -&gt;with('fail', 'Profile is unable to be update successfully');
          }
      } else {
  
          return redirect()
              -&gt;route('login')
              -&gt;with('fail', 'Profile is unable to be update successfully 
      because ur not an Admin');
      }
  </code></pre>