title: send to repository class variable laravel from controller
body: <p>i´m traying to do query into my repository to get galleries that to have a restaurant and i need seach for id. One restaurant´s gallery only can to have 10 images, but we can to have more than one restaurant. I need that when one restaurant will have a 10 images, it can´t upload any more and disable this restaurant.</p>
  <p>sorry for my english, i hope that i can explain me correctly.</p>
  <p><strong>my controller:</strong></p>
  <pre><code>if (auth()-&gt;user()-&gt;hasRole('admin')){
              $restaurant = $this-&gt;restaurantRepository-&gt;pluck('name', 'id');
          }else{
              $restaurant = $this-&gt;restaurantRepository-&gt;galleries()-&gt;myActiveRestaurants()-&gt;pluck('name', 'id');
          }
          // get all media gallery of restaurant
          //$media = $this-&gt;galleryRepository-&gt;getCountMedia();
          foreach($restaurant as $res){
              $res-&gt;cg = (count($res-&gt;galleries()-&gt;get()) == 10);
          }
  
          $hasCustomField = in_array($this-&gt;galleryRepository-&gt;model(), setting('custom_field_models', []));
          if ($hasCustomField) {
              $customFields = $this-&gt;customFieldRepository-&gt;findByField('custom_field_model', $this-&gt;galleryRepository-&gt;model());
              $html = generateCustomField($customFields);
          }
          return view('galleries.create')-&gt;with(&quot;customFields&quot;, isset($html) ? $html : false)-&gt;with(&quot;restaurant&quot;, $restaurant)/*-&gt;with('imagesRestaurant', $media)*/;
  </code></pre>
  <p>here i´m calling to model function galleries() where i have a function to get, <code>restaurant_id</code></p>
  <p>but in my web, result is:</p>
  <pre><code>Call to a member function galleries() on string
  </code></pre>
  <p>i need to get <code>restaurant_id</code> for call here <code>my repository</code>:</p>
  <pre><code>public function getCountMedia(){
          return Gallery::join(&quot;user_restaurants&quot;, &quot;user_restaurants.restaurant_id&quot;, &quot;=&quot;, &quot;galleries.restaurant_id&quot;)
                          -&gt;where('user_restaurants.user_id', auth()-&gt;id())-&gt;count();
      }
  </code></pre>
  <p>i don´t want <code>auth()-&gt;id()</code> i need <code>restaurant_id</code> for in my controller extract that restaurant to have 10 image</p>
  <p>i hope that any can help me, please</p>
  <p><strong>updated</strong></p>
  <p>i´m instaciate class in construct:</p>
  <pre><code>public function __construct(GalleryRepository $galleryRepo, CustomFieldRepository $customFieldRepo, UploadRepository $uploadRepo
          , RestaurantRepository $restaurantRepo)
      {
          parent::__construct();
          $this-&gt;galleryRepository = $galleryRepo;
          $this-&gt;customFieldRepository = $customFieldRepo;
          $this-&gt;uploadRepository = $uploadRepo;
          $this-&gt;restaurantRepository = $restaurantRepo;
      }
  </code></pre>
  <p>i can show now, that <code>restaurant_id</code> it´s in galleries table, but i don´t know how to access to this property</p>
  <p><strong>updated2</strong></p>
  <p>i change my controller and repository:</p>
  <p><strong>controller</strong></p>
  <pre><code>// get all media gallery of restaurant
  foreach($restaurant as $res =&gt; $id){
     $media[] = $this-&gt;galleryRepository-&gt;getCountMedia($res);
  }
  return view('galleries.create')-&gt;with(&quot;customFields&quot;, isset($html) ? $html : false)-&gt;with(&quot;restaurant&quot;, $restaurant)-&gt;with('imagesRestaurant', $media);
  </code></pre>
  <p><strong>repository</strong></p>
  <pre><code>public function getCountMedia($restaurantId){
          return Gallery::join(&quot;user_restaurants&quot;, &quot;user_restaurants.restaurant_id&quot;, &quot;=&quot;, &quot;galleries.restaurant_id&quot;)
                          -&gt;where('galleries.restaurant_id', $restaurantId)-&gt;count();
      }
  </code></pre>
  <p>with this i get id for restaurant, and in blade i need disable option that value greater than 10 but, only get duplicate select...</p>
  <p><strong>blade:</strong></p>
  <pre><code>@foreach($imagesRestaurant as $images)
        {{$images}}
      
        @if($images &gt;= 10)
          {!! Form::select('restaurant_id', $restaurant, null, ['class' =&gt; 'select2 form-control']) !!}
        @else
          {!! Form::select('restaurant_id', $restaurant, null, ['class' =&gt; 'form-control', 'disabled' =&gt; true]) !!}
        @endif
      @endforeach
  </code></pre>