title: Laravel factory Argument 1 passed to Illuminate\Database\Grammar::parameterize() must be of the type array, string given
body: <p>I get this error when trying to run a factory in laravel 8. I've looked though several posts about this error but they all seem to come from saving/creating directly incorrectly. Not using a factory. So I am not sure why the factory isn't saving it correctly.</p>
  <p>My migration has:</p>
  <pre><code>public function up()
  {
      Schema::create('posts', function (Blueprint $table) {
          $table-&gt;id();
          $table-&gt;string('slug');
          $table-&gt;string('name');
          $table-&gt;longText('desc');
          $table-&gt;foreignId('user_id')-&gt;constrained();
          $table-&gt;timestamps();
          $table-&gt;softDeletes();
      });
  }
  </code></pre>
  <p>My model has:</p>
  <pre><code>class Post extends Model
  {
      use HasFactory, SoftDeletes;
  
      public function user()
      {
          return $this-&gt;belongsTo(User::class);
      }
  
      public function setSlugAttribute($value)
      {
          $this-&gt;attributes['slug'] = Str::slug($this-&gt;name);
      }
  }
  </code></pre>
  <p>My factory has:</p>
  <pre><code>public function definition()
  {
      return [
          'name' =&gt; $this-&gt;faker-&gt;words,
          'desc' =&gt; $this-&gt;faker-&gt;sentence,
          'user_id' =&gt; rand(1,10)
      ];
  }
  </code></pre>
  <p>And my Posts seeder has:</p>
  <pre><code>public function run()
  {
      Post::factory()-&gt;times(13)-&gt;create();
  }
  </code></pre>
  <p>My main DatabaseSeeder runs a user seeder that seeds 10 users. Then a post seeder to seed 13 posts.</p>
  <p>I run <code>php artisan migrate:fresh --seed</code> and it fails when it gets to the Post Seeder with this error:</p>
  <blockquote>
  <p>TypeError</p>
  <p>Argument 1 passed to Illuminate\Database\Grammar::parameterize()
  must be of the type array, string given, called in
  /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php
  on line 886</p>
  <p>at vendor/laravel/framework/src/Illuminate/Database/Grammar.php:136
  132▕      *
  133▕      * @param  array  $values
  134▕      * @return string
  135▕      */   ➜ 136▕     public function parameterize(array $values)
  137▕     {
  138▕         return implode(', ', array_map([$this, 'parameter'], $values));
  139▕     }
  140▕</p>
  <pre><code>  +1 vendor frames    2   [internal]:0
    Illuminate\Database\Query\Grammars\Grammar::Illuminate\Database\Query\Grammars\{closure}(&quot;Odio
  </code></pre>
  <p>voluptatem quis facere possimus ut.&quot;, &quot;desc&quot;)</p>
  <pre><code>  +13 vendor frames    16  database/seeders/PostsSeeder.php:17
    Illuminate\Database\Eloquent\Factories\Factory::create()
  </code></pre>
  </blockquote>
  <p>I'm really not understanding why its expecting an array for a string column.</p>