title: How to solved in Laravel relations null value
body: <p><a href="https://i.stack.imgur.com/Ywk0m.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ywk0m.png" alt="enter image description here"></a>Im tru to use to last version of laravel and i have small problem with Laravel relationship One to Many
  Im try to connect products with categories</p>
  
  <p>This is my code of Product model</p>
  
  <pre><code>public function categories()
  {
      return $this-&gt;belongsTo('App\Category');
  }
  </code></pre>
  
  <p>this is my code of Category model</p>
  
  <pre><code>public function products()
  {
      return $this-&gt;hasMany('App\Product');
  }
  </code></pre>
  
  <p>This is my code in controller</p>
  
  <pre><code>$products = Product::with('categories')-&gt;get();
      dd($products);
  </code></pre>
  
  <p>this is my code from migration files </p>
  
  <pre><code>Schema::create('products', function (Blueprint $table) {
          $table-&gt;id();
          $table-&gt;unsignedBigInteger('category_id');
          $table-&gt;string('name')-&gt;unique();
          $table-&gt;string('slug')-&gt;unique();
          $table-&gt;string('keywords')-&gt;nullable();
          $table-&gt;string('price');
          $table-&gt;text('description')-&gt;nullable();
          $table-&gt;text('image')-&gt;nullable();
          $table-&gt;timestamps();
          $table-&gt;foreign('category_id')-&gt;references('id')-&gt;on('categories');
      });
  
  Schema::create('categories', function (Blueprint $table) {
          $table-&gt;id();
          $table-&gt;string('name')-&gt;unique();
          $table-&gt;string('slug')-&gt;unique();
          $table-&gt;string('keywords')-&gt;nullable();
          $table-&gt;timestamps();
      });[![enter image description here][1]][1]
  </code></pre>
  
  <p>If someone know how to solved this problem I'll be very grateful</p>