title: Problem with displaying user-pictures relation in Laravel 5.8
body: <p>I'm very beginner in Laravel.</p>
  
  <p>I have standard login User model (generated by Laravel):</p>
  
  <pre><code>class UploadedFiles extends Model
  {
      protected $quarded = [];
      protected $fillable = ['company_id', 'enable', 'photoable_type', 'photoable_id', 'path', 'ip', 'number'];
      protected $table = 'uploaded_files';
  
  
  }
  
  
  class User extends Authenticatable implements MustVerifyEmail
  {
      use Notifiable;
      use psCMS\Presenters\UserPresenter;
  
      public static $roles = [];
  
      /**
       * The attributes that are mass assignable.
       *
       * @var array
       */
  
      protected $fillable = ['company_id', 'enable', 'name', 'surname', 'email', 'email_verified_at', 'password', 'counter', 'url_address',  'isCompany', 'isMailing', 'content', 'nip1', 'business1', 'phone1', 'street1', 'number1', 'postal_code1', 'city1', 'country_id1', 'provincial_id1', 'nip2', 'business2', 'phone2', 'street2', 'number2', 'postal_code2', 'city2', 'country_id2', 'provincial_id2', 'nip3', 'business3', 'phone3', 'street3', 'number3', 'postal_code3', 'city3', 'country_id3', 'provincial_id3', 'cash', 'lng', 'lat', 'enable_map', 'remember_token', 'created_at', 'updated_at', 'last_login_at', 'last_login_ip' ];
  
  
      /**
       * The attributes that should be hidden for arrays.
       *
       * @var array
       */
      protected $hidden = [
          'password', 'remember_token',
      ];
  
  
      public function roles()
      {
          return $this-&gt;belongsToMany('App\Role');
      }
  
      public function mainRole()
      {
          return $this-&gt;hasOne('App\Role');
      }
  
      public function comments()
      {
          return $this-&gt;hasMany('App\Comments');
      }
  
  
      public function images()
      {   // find(['photoable_type', '=', 'AdminImage'] ::with('director')-&gt;get();
          return $this-&gt;hasMany('App\UploadedFiles' );
      }
  
      public function images2()
      {   // -&gt;where('photoable_type', 'AdminImage')
          return $this-&gt;hasManyThrough('App\UploadedFiles', 'App\User', 'photoable_id', 'id');
      }
  
      public function hasRole(array $roles)
      {
  
          foreach($roles as $role)
          {
  
              if(isset(self::$roles[$role]))
              {
                  if(self::$roles[$role])  return true;
  
              }
              else
              {
                  self::$roles[$role] = $this-&gt;roles()-&gt;where('name', $role)-&gt;exists();
                  if(self::$roles[$role]) return true;
              }
  
          }
          return false;
      }
  
      public function loginHistory()
      {
          return $this-&gt;hasMany('App\UserLoginHistory');
      }
  
      public function companies()
      {
          return $this-&gt;belongsTo('App\Companies','company_id');
      }
  
  
  
  }
  </code></pre>
  
  <p>My schema:</p>
  
  <pre><code>Schema::create('users', function (Blueprint $table) {
              $table-&gt;bigIncrements('id');
              $table-&gt;bigInteger('company_id')-&gt;unsigned();
              $table-&gt;foreign('company_id')-&gt;references('id')-&gt;on('companies')-&gt;onDelete('cascade');
              $table-&gt;boolean('enable')-&gt;default(0);
              $table-&gt;string('name', 120)-&gt;nullable();
              $table-&gt;string('surname', 120)-&gt;nullable();
              $table-&gt;string('email', 120)-&gt;unique();
              $table-&gt;timestamp('email_verified_at')-&gt;nullable();
              $table-&gt;string('password');
              $table-&gt;bigInteger('counter')-&gt;default(0);
              $table-&gt;string('url_address', 160);
              $table-&gt;boolean('isCompany')-&gt;default(0);
              $table-&gt;boolean('isMailing')-&gt;default(0);
              $table-&gt;text('content')-&gt;nullable();
              $table-&gt;string('nip1', 12)-&gt;nullable();
              $table-&gt;string('business1', 120)-&gt;nullable();
              $table-&gt;string('phone1', 60)-&gt;nullable();
              $table-&gt;string('street1', 150)-&gt;nullable();
              $table-&gt;string('number1', 8)-&gt;nullable();
              $table-&gt;string('postal_code1', 12)-&gt;nullable();
              $table-&gt;string('city1', 100)-&gt;nullable();
              $table-&gt;bigInteger('country_id1')-&gt;default(0);
              $table-&gt;bigInteger('provincial_id1')-&gt;default(0);
              $table-&gt;string('nip2', 12)-&gt;nullable();
              $table-&gt;string('business2', 120)-&gt;nullable();
              $table-&gt;string('phone2', 60)-&gt;nullable();
              $table-&gt;string('street2', 150)-&gt;nullable();
              $table-&gt;string('number2', 8)-&gt;nullable();
              $table-&gt;string('postal_code2', 12)-&gt;nullable();
              $table-&gt;string('city2', 100)-&gt;nullable();
              $table-&gt;bigInteger('country_id2')-&gt;default(0);
              $table-&gt;bigInteger('provincial_id2')-&gt;default(0);
              $table-&gt;string('nip3', 12)-&gt;nullable();
              $table-&gt;string('business3', 120)-&gt;nullable();
              $table-&gt;string('phone3', 60)-&gt;nullable();
              $table-&gt;string('street3', 150)-&gt;nullable();
              $table-&gt;string('number3', 8)-&gt;nullable();
              $table-&gt;string('postal_code3', 12)-&gt;nullable();
              $table-&gt;string('city3', 100)-&gt;nullable();
              $table-&gt;bigInteger('country_id3')-&gt;default(0);
              $table-&gt;bigInteger('provincial_id3')-&gt;default(0);
              $table-&gt;decimal('cash', 9, 2)-&gt;default(0);
              $table-&gt;decimal('lng', 10, 8)-&gt;default(0);
              $table-&gt;decimal('lat', 10, 8)-&gt;default(0);
              $table-&gt;boolean('enable_map')-&gt;default(0);
              $table-&gt;rememberToken();
              $table-&gt;timestamps();
              $table-&gt;engine = "InnoDB";
          });
  
  
  
  
  Schema::create('role_user', function (Blueprint $table) {
              $table-&gt;bigInteger('user_id')-&gt;unsigned();
              $table-&gt;foreign('user_id')-&gt;references('id')-&gt;on('users')-&gt;onDelete('cascade');
              $table-&gt;bigInteger('role_id')-&gt;unsigned();
              $table-&gt;foreign('role_id')-&gt;references('id')-&gt;on('roles')-&gt;onDelete('cascade');
              $table-&gt;engine = "InnoDB";
          });
  
  
  
  Schema::create('roles', function (Blueprint $table) {
              $table-&gt;bigIncrements('id');
              $table-&gt;string('name');
              $table-&gt;engine = "InnoDB";
          });
  
  
  
  Schema::create('uploaded_files', function (Blueprint $table) {
              $table-&gt;bigIncrements('id');
              $table-&gt;bigInteger('company_id')-&gt;unsigned();
              $table-&gt;foreign('company_id')-&gt;references('id')-&gt;on('companies')-&gt;onDelete('cascade');
              $table-&gt;boolean('enable')-&gt;default(0);
              $table-&gt;string('photoable_type', 150);
              $table-&gt;integer('photoable_id');
              $table-&gt;string('path', 255);
              $table-&gt;string('ip', 25);
              $table-&gt;bigInteger('number')-&gt;default(0);
              $table-&gt;timestamps();
              $table-&gt;engine = "InnoDB";
          });
  </code></pre>
  
  <p>I have the following record in the database:
  <a href="https://ibb.co/ZhHGkKX" rel="nofollow noreferrer">https://ibb.co/ZhHGkKX</a></p>
  
  <pre><code>INSERT INTO `uploaded_files` (`id`, `company_id`, `enable`, `photoable_type`, `photoable_id`, `path`, `ip`, `number`, `created_at`, `updated_at`) VALUES
  (46, 1, 1, 'AdminImage', 1, 'upload/images/AdminImage/627e653871183f639c8d9460f37111b1.jpg', '172.29.0.1', 0, '2019-05-27 08:50:08', '2019-05-27 08:50:08');
  COMMIT;
  </code></pre>
  
  <p>In my base I have relations:
  - uploaded_files.photoable_id = User.id</p>
  
  <p>I need to display all images belonging to the user that have the photoable_type = AdminImage</p>
  
  <p>How can I do this? Please help</p>