title: One-To-Many Eloquent relation isn't working with irregular words
body: <p>I've got categories->subcategories one to many relation (one category can have many subcategories) but I can't get this to work, I've tried basically everything and don't know what to do next.</p>
  
  <p><strong>My migrations and seeds:</strong></p>
  
  <pre><code>Categories:
  
  
  Schema::create('categories', function (Blueprint $table) {
              $table-&gt;increments('id');
              $table-&gt;string('name');
              $table-&gt;text('description');
              $table-&gt;string('image_url');
              $table-&gt;timestamps();
          });
  
  
  ---------
  
  DB::table('categories')-&gt;insert([[
              'id' =&gt; 1,
              'name' =&gt; 'Verbs',
              'description' =&gt; 'Lorem ipsum dolor sit amet',
              'image_url' =&gt; ''
          ],[
              'id' =&gt; 2,
              'name' =&gt; 'Nouns',
              'description' =&gt; 'Lorem ipsum dolor sit amet',
              'image_url' =&gt; ''
          ],[
              'id' =&gt; 3,
              'name' =&gt; 'Idioms',
              'description' =&gt; 'Lorem ipsum dolor sit amet',
              'image_url' =&gt; ''
          ],[
              'id' =&gt; 4,
              'name' =&gt; 'Adjectives',
              'description' =&gt; 'Lorem ipsum dolor sit amet',
              'image_url' =&gt; ''
          ]
          ]);
  
  
  Subcategories:
  
  Schema::create('subcategories', function (Blueprint $table) {
              $table-&gt;increments('id');
              $table-&gt;string('name');
              $table-&gt;text('description');
              $table-&gt;string('image_url');
              $table-&gt;integer('category_id')-&gt;unsigned()-&gt;index;
              $table-&gt;timestamps();
          });
  
  ---------
  
  DB::table('subcategories')-&gt;insert([[
              'id' =&gt; 1,
              'name' =&gt; 'Sport verbs',
              'description' =&gt; 'Lorem ipsum dolor sit amet',
              'image_url' =&gt; '',
              'category_id' =&gt; DB::table('categories')-&gt;where('name', 'Verbs')-&gt;pluck('id')-&gt;first()
          ],[
              'id' =&gt; 2,
              'name' =&gt; 'Cooking verbs',
              'description' =&gt; 'Lorem ipsum dolor sit amet',
              'image_url' =&gt; '',
              'category_id' =&gt; DB::table('categories')-&gt;where('name', 'Verbs')-&gt;pluck('id')-&gt;first()
          ],[
              'id' =&gt; 3,
              'name' =&gt; 'Business verbs',
              'description' =&gt; 'Lorem ipsum dolor sit amet',
              'image_url' =&gt; '',
              'category_id' =&gt; DB::table('categories')-&gt;where('name', 'Verbs')-&gt;pluck('id')-&gt;first()
          ],[
              'id' =&gt; 4,
              'name' =&gt; 'School verbs',
              'description' =&gt; 'Lorem ipsum dolor sit amet',
              'image_url' =&gt; '',
              'category_id' =&gt; DB::table('categories')-&gt;where('name', 'Verbs')-&gt;pluck('id')-&gt;first()
          ],[
              'id' =&gt; 5,
              'name' =&gt; 'Sport nouns',
              'description' =&gt; 'Lorem ipsum dolor sit amet',
              'image_url' =&gt; '',
              'category_id' =&gt; DB::table('categories')-&gt;where('name', 'Nouns')-&gt;pluck('id')-&gt;first()
          ],[
              'id' =&gt; 6,
              'name' =&gt; 'Sport idioms',
              'description' =&gt; 'Lorem ipsum dolor sit amet',
              'image_url' =&gt; '',
              'category_id' =&gt; DB::table('categories')-&gt;where('name', 'Idioms')-&gt;pluck('id')-&gt;first()
          ],[
              'id' =&gt; 7,
              'name' =&gt; 'Sport adjectives',
              'description' =&gt; 'Lorem ipsum dolor sit amet',
              'image_url' =&gt; '',
              'category_id' =&gt; DB::table('categories')-&gt;where('name', 'Adjectives')-&gt;pluck('id')-&gt;first()
          ],
          ]);
  </code></pre>
  
  <p><strong>Models:</strong></p>
  
  <p><strong>Category:</strong></p>
  
  <pre><code>namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  use App\Subcategory;
  
  class Category extends Model
  {
      protected $table = 'categories';
      protected $fillable = ['name', 'description', 'image_url', 'id'];
  
      public function subcategories()
      {
          return $this-&gt;hasMany(Subcategory::class, 'category_id');
      }
  }
  </code></pre>
  
  <p><strong>Subcategory:</strong></p>
  
  <pre><code>namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  use App\Category;
  
  class Subcategory extends Model
  {
      protected $table = 'subcategories';
      protected $fillable = ['name', 'description', 'image_url', 'category_id', 'id'];
  
      public function category()
      {
          return $this-&gt;belongsTo(Category::class, 'category_id');
      }
  }
  </code></pre>
  
  <p>And in controller:</p>
  
  <pre><code>class CategoriesController extends Controller
  {
      public function index($id)
      {
          $subcategories = Category::findOrFail($id)-&gt;subcategories();
          foreach ($subcategories as $subcategory)
              echo $subcategory-&gt;name . '&lt;br&gt;';
      }
  }
  </code></pre>
  
  <p><strong>Route:</strong></p>
  
  <pre><code>Route::get('/category/{id}', 'CategoriesController@index');
  </code></pre>
  
  <p>So it's on url <code>website.test/category/1</code></p>
  
  <p>but it returns me nothing. If I just print name of category (so just work with category without its subcategories relations) it works. Just relations don't. I really have no idea already what can I do. Do you have any ideas?</p>
  
  <p>Regards :)</p>