title: how to Check Model Data Exists In another Table
body: <p>i'm trying to get All RequestStates Where DepartMent_id 's equals with  my department_id
  But before returning the result, it should be checked that the User_Id field  doesn't exists
  in Graduate Table</p>
  <p>this is my code :</p>
  <pre><code>$request=RequestState::where('department_id',auth()-&gt;user()-&gt;department_id)-&gt;get();
  </code></pre>
  <p>Relations:</p>
  <p><strong>Request</strong> HasMany <strong>Request_State</strong></p>
  <p><strong>User</strong> Has One <strong>Graduate</strong></p>
  <p>Tables :</p>
  <p><strong>Reqeuest_STATE TABLE</strong> :</p>
  <p><a href="https://i.stack.imgur.com/0Um6O.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0Um6O.png" alt="request state table" /></a></p>
  <p><strong>USER TABLE</strong></p>
  <p><a href="https://i.stack.imgur.com/1WFxE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1WFxE.png" alt="user table" /></a></p>
  <p><strong>Request Table:</strong></p>
  <p><a href="https://i.stack.imgur.com/LxExN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LxExN.png" alt="enter image description here" /></a></p>
  <p><strong>Graduate Table</strong></p>
  <p><a href="https://i.stack.imgur.com/TgAVp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TgAVp.png" alt="enter image description here" /></a></p>