title: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'cat_id' cannot be null
body: <p>I'm getting this error while up entering data to my table</p>
  
  <pre><code>class EntryController extends Controller
  {
      /**
       * Create a new controller instance.
       *
       * @return void
       */
  
  
      /**
       * Show the application dashboard.
       *
       * @return \Illuminate\Http\Response
       */
  
      public function entry(Request $request){
  
          $category = category::create(['cat_name' =&gt; $request-&gt;input('cat_name')]);
  
           $product= product::create([
              'Product_name'=&gt;$request-&gt;input('Product_name'),
              'Produc_quantity'=&gt;$request-&gt;input('Produc_quantity'),
              'Product_Desc' =&gt;$request-&gt;input('Product_Desc'), 
              'cat_id'=&gt;$category-&gt;cat_id]);
  
  
  class category extends Model
  {
      protected $fillable = array('cat_description','cat_name');
  
  
      public function product()
      {
          return $this-&gt;hasMany(product::class);
  
  
      }
  //
  }
  </code></pre>
  
  <p>these are my models</p>
  
  <pre><code>class product extends Model
  {
      protected   $fillable = array('Product_name','Product_Desc',
                                    'Produc_quantity','sale_price',
                                    'cost_price');
      public function category()
      {
          return $this-&gt;belongsTo(category::class);
  
  
      }
          //
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/Zg7zO.png" alt="this is product table"></p>
  
  <p><img src="https://i.stack.imgur.com/LCytW.png" alt="this is category table"></p>
  
  <p>I've removed the cat_id from $fillables in product model and this is giving this error and I'm not understanding this I've check many forums and questions but I didn't find an answer
  this is product table</p>
  
  <pre><code> Schema::create('products', function (Blueprint $table) {
          $table-&gt;increments('product_id');
          $table-&gt;string('Product_name');
          $table-&gt;string('Product_Desc');
          $table-&gt;integer('sale_price');
          $table-&gt;integer('cost_price');
          $table-&gt;integer('Produc_quantity');
         $table-&gt;integer('cat_id')-&gt;unsigned();
          $table-&gt;foreign('cat_id')-&gt;references('cat_id')-&gt;on('categories');
          $table-&gt;timestamps();
  </code></pre>
  
  <p>this is category table</p>
  
  <pre><code>  Schema::create('categories', function (Blueprint $table) {
          $table-&gt;increments('cat_id');
          $table-&gt;string('cat_name');
          $table-&gt;string('cat_description');
  
  
          $table-&gt;timestamps();
  </code></pre>