In form below my user share document access with other users.
How to increase my selector to show me only user who are not shared with this document yet? Document and User has pivot table document_user
<select type="text" name="user" class="uk-select">
<option disabled selected>Choose from contacts</option>
@foreach($company->users as $contact)
//@if (something)
<option value="{{ $contact->id }}">{{ $contact->first_name}} {{ $contact->last_name}}</option>
@andif
@endforeach
</select>
Document = $document
Tables:
user:
- id
- name
document:
- id;
- company_id
- name
document_user: - company_id - user_id
public function users() { return $this->belongsToMany(User::class, 'document_user'); }- Philipp Kishkovarovhasmanyin user shoulld change tobelongs to many- iamab.in