title: array_map(): Argument #2 should be an array
body: <p>I'm getting this error<code>array_map(): Argument #2 should be an array</code> when a user trying to create a product</p>
  
  <p>I changed my code from this solutions <a href="https://stackoverflow.com/questions/56496813/how-to-make-each-authenticated-user-only-see-their-own-product">How to make each authenticated user only see their own product</a>, and now it gives me that error. </p>
  
  <p>ProductController</p>
  
  <pre><code>class productController extends Controller
  {
  
  public function index(Request $request)
  {
      $userId = $request-&gt;user()-&gt;id;
      $products = products_model::where('user_id', $userId)-&gt;get();
     return view('seller.product.index',compact('products'));
  }
  
  
  
  
  public function create()
  {  
      return view('seller.product.create');
  }
  
  public function seller()
  {
     $products=products_model::all();
     return view('seller.product.index',compact('products'));
  }
  
  
  public function store(Request $request)
  {
  
      $formInput=$request-&gt;except('image');
      $this-&gt;validate($request, [
       'pro_name'=&gt; 'required',
       'pro_price'=&gt; 'required',
       'pro_info'=&gt; 'required',
       'user_id' =&gt; \Auth::id(),
       'image'=&gt;'image|mimes:png,jpg,jpeg|max:10000'
      ]);
  
      $image=$request-&gt;image;
      if($image){
          $imageName=$image-&gt;getClientOriginalName();
          $image-&gt;move('images', $imageName);
          $formInput['image']=$imageName;
      }
  
      products_model::create($formInput);
      return redirect()-&gt;back();
  }
  
  
  public function show($id)
  {
      //
  }
  
  
  public function edit($id)
  {
      //
  }
  
  
  public function update(Request $request, $id)
  {
      //
  }
  
  
  public function destroy($id)
  {
     $userId = $request-&gt;user()-&gt;id();
     $deleteData=products_model::where('user_id', $userId)-&gt;findOrFail($id);
     $deleteData-&gt;delete();
  
     return redirect()-&gt;back();
  }
  }
  </code></pre>
  
  <p>Products_model</p>
  
  <pre><code>class products_model extends Model
  {
  protected $table='products';
  protected $primaryKey='id';
  protected $fillable= ['user_id','pro_name','pro_price','pro_info','image','stock','category_ id'];
  }
  </code></pre>
  
  <p>Products table</p>
  
  <pre><code>class CreateProductsTable extends Migration
  {
  
  public function up()
  {
      Schema::create('products', function (Blueprint $table) {
          $table-&gt;bigIncrements('id');
          $table-&gt;string('pro_name');
          $table-&gt;integer('pro_price');
          $table-&gt;text('pro_info');
          $table-&gt;integer('stock');
          $table-&gt;string('image')-&gt;nullable();
          $table-&gt;timestamps();
  
          $table-&gt;bigInteger('user_id')-&gt;unsigned()-&gt;index();
          $table-&gt;foreign('user_id')-&gt;references('id')-&gt;on('users')-&gt;onDelete('cascade');
      });
  }
  
  
  public function down()
  {
      Schema::dropIfExists('products');
  }
  }
  </code></pre>
  
  <p>After updating my code now am getting this error<code>SQLSTATE[HY000]: General error: 1364 Field 'user_id' doesn't have a default value (SQL: insert into</code>products<code>(</code>pro_name<code>,</code>pro_price<code>,</code>stock<code>,</code>pro_info<code>,</code>i`</p>