title: Laravel resource index listing limited amount of records
body: <p>I have two resources</p>
  <ul>
  <li><p>Organizations</p>
  </li>
  <li><p>OrganizationUsers (which has FK to Users on <code>user_id</code>)</p>
  </li>
  </ul>
  <p>The User model</p>
  <pre><code>class User extends Authenticatable
  {
      use Notifiable;
  
      /**
       * The attributes that are mass assignable.
       *
       * @var array
       */
      protected $fillable = [
          'name', 'email', 'password', 'picture' ,'role_id'
      ];
  
      /**
       * The attributes that should be hidden for arrays.
       *
       * @var array
       */
      protected $hidden = [
          'password', 'remember_token',
      ];
  
      /**
       * Get the role of the user
       *
       * @return \App\Role
       */
      public function role()
      {
          return $this-&gt;belongsTo(Role::class);
      }
  
      /**
       * Get the path to the profile picture
       *
       * @return string
       */
      public function profilePicture()
      {
          if ($this-&gt;picture) {
              return &quot;/{$this-&gt;picture}&quot;;
          }
  
          return 'http://i.pravatar.cc/200';
      }
  
      /**
       * Check if the user has admin role
       *
       * @return boolean
       */
      public function isAdmin()
      {
          return $this-&gt;role_id == 1;
      }
  
      /**
       * Check if the user has creator role
       *
       * @return boolean
       */
      public function isCreator()
      {
          return $this-&gt;role_id == 2;
      }
  
      /**
       * Check if the user has user role
       *
       * @return boolean
       */
      public function isMember()
      {
          return $this-&gt;role_id == 3;
      }
  
      /**
       * The organization_user that belong to the user.
       *
       * @return \Illuminate\Database\Eloquent\Collection
       */
      public function organizations()
      {
          return $this-&gt;belongsToMany(OrganizationUser::class);
      }
  }
  </code></pre>
  <p>, the Organization model is</p>
  <pre><code>class Organization extends Model
  {
      protected $fillable = [
          'user_id', 'name' , 'slug', 'is_visible'
      ];
  
      /**
       * Get the user owner of the organization
       *
       * @return \App\User
       */
      public function user()
      {
          return $this-&gt;belongsTo(User::class);
      }
  }
  </code></pre>
  <p>and the OrganizationUser model is</p>
  <pre><code>class OrganizationUser extends Model
  {
      protected $fillable = [
          'user_id', 'organization_id', 'is_admin', 'name'
      ];
  
      /**
       * Get the user
       *
       * @return \App\User
       */
      public function user()
      {
          return $this-&gt;belongsToMany(User::class);
      }
  
      /**
       * Get the organization
       *
       * @return \Organization
       */
      public function organization()
      {
          return $this-&gt;belongsTo(Organization::class);
      }
  
      /**
       * Check if the user is_admin
       *
       * @return boolean
       */
      public function isAdmin()
      {
          return $this-&gt;is_admin == 1;
      }
  
  }
  </code></pre>
  <p>When it comes to access these resources</p>
  <pre><code>Route::resource('organization', 'OrganizationController');
  Route::resource('organizationuser', 'OrganizationUserController', ['except' =&gt; ['show']]);
  </code></pre>
  <p>Also, this is the index() of the OrganizationController</p>
  <pre><code>class OrganizationController extends Controller
  {
      /**
       * Display a listing of the organizations
       *
       * @param \App\Organization  $model
       * @return \Illuminate\View\View
       */
      public function index(Organization $model)
      {
          $this-&gt;authorize('manage-users', User::class);
  
          return view('organizations.index', ['organizations' =&gt; $model-&gt;all()]);
      }
      
      ...
  }
  </code></pre>
  <p>and the navigation</p>
  <pre><code>@can('manage-organizations', App\User::class)
                  &lt;li class=&quot;nav-item {{ $elementName == 'organization-management' ? 'active' : '' }}&quot;&gt;
                      &lt;a class=&quot;nav-link&quot; href=&quot;{{ route('organization.index') }}&quot;&gt;
                          &lt;i class=&quot;ni ni-briefcase-24&quot; style=&quot;color: #1E73BE;&quot;&gt;&lt;/i&gt;
                          &lt;span class=&quot;nav-link-text&quot;&gt;{{ __('Organizations') }}&lt;/span&gt;
                      &lt;/a&gt;
                  &lt;/li&gt;
                  @endcan
  </code></pre>
  <p>Instead of seeing all of Organizations when going to the index of that resource, I'd like it to list all Organizations where the authenticated user is one of the OrganizationUsers.</p>
  <p>How can that be done?</p>
  <p>This question has similarities with <a href="https://stackoverflow.com/q/50924851/5675325">this one</a> but it's with a different take.</p>