title: cannot retrieve Category model with related items
body: <p>I have very strange error in my laravel website.
  I try to retrieve Category model <strong>with</strong> related items, but looking at the error I see that laravel tries to retrieve items field from category model and of course it fails. But I am completely cannot understand why it happens, because I have the same code working well in other parts of my website.</p>
  <p><strong>routes/web.php</strong></p>
  <pre><code>Route::name('gallery.')-&gt;prefix('gallery')-&gt;group(function () {
      Route::get('/',       'GalleryController@index')-&gt;name('index');
      Route::get('/{slug}', 'GalleryController@item')-&gt;name('item');
  });
  </code></pre>
  <p><strong>GalleryController</strong></p>
  <pre><code>    public function item($slug)
      {
  
          $category = $this-&gt;imageRepository-&gt;getCategoryWithPaginatedImages($slug, $perPage = 20);
  
          return view('pages.gallery.item', compact('category'));
      }
  </code></pre>
  <p><strong>ImageRepository</strong></p>
  <pre><code>
  namespace App\Repositories;
  
  use Illuminate\Database\Eloquent\Collection;
  use App\Models\ImageCategory as Model;
  
  
  class ImageRepository extends CoreRepository
  {
  
      protected function getModelClass()
      {
          return Model::class;
      }
  
      public function getCategoryWithPaginatedImages($slug, $perPage = null)
      {
          $columns = ['id','title','slug','description','image','published','metatitle','metakey','metadesc'];
  
          $result = $this
              -&gt;startConditions()
              -&gt;whereSlug($slug)
              -&gt;select($columns)
              -&gt;with('images:id,title,category_id,md,lg') 
              -&gt;firstOrFail()
              -&gt;toArray();
  
          $result = Arr::arrayToObject($result);
          $result-&gt;items = collect($result-&gt;items)-&gt;mypaginate($perPage);
  
          return $result;
      }
  
  }
  </code></pre>
  <p><strong>Image</strong></p>
  <pre><code>namespace App\Models;
  use Illuminate\Database\Eloquent\Model;
  
  class Image extends Model
  {
  
      protected $guarded = [];
      public function category() { return $this-&gt;belongsTo(ImageCategory::class); }
  
  }
  </code></pre>
  <p><strong>ImageCategory</strong></p>
  <pre><code>namespace App\Models;
  use Illuminate\Database\Eloquent\Model;
  
  class ImageCategory extends Model
  {
  
      protected $guarded = [];
      public    $timestamps = false;
      public function images() { return $this-&gt;hasMany(ImageCategory::class, 'category_id'); }
  }
  </code></pre>
  <p>so when I hit <code>gallery/slug</code> then <code>getCategoryWithPaginatedImages</code> gives me following error</p>
  <pre><code>Illuminate\Database\QueryException
  SQLSTATE[42S22]: Column not found: 1054 Unknown column 'category_id' in 'field list' (SQL: select `id`, `title`, `category_id`, `md`, `lg` from `image_categories` where `image_categories`.`category_id` in (2))
  </code></pre>