title: Insert data into database manually inside a laravel 5 controller without a form
body: <p>I need to insert some data into a sqlite database, manually inside a (Laravel 5) controller and without a form.</p>
  
  <p>I've tried with this methods:</p>
  
  <p>1st:</p>
  
  <pre><code>DB::insert('insert into cars values (?, ?, ?)', [1, "Infinity", "MS500"]);
  </code></pre>
  
  <p>2nd:</p>
  
  <pre><code>Car::create([
      'brand' =&gt; 'Infinity',
      'model' =&gt; 'MS500',
  ]);
  </code></pre>
  
  <p>3rd:</p>
  
  <pre><code>$car = new Car();
  $car-&gt;setAttribute('brand', 'Infinity');
  $car-&gt;setAttribute('model', 'MS500');
  $car-&gt;save();
  </code></pre>
  
  <p>The <strong>1st</strong> method works, but I need to insert thousand of rows, and <strong>the time and performance is not so good.</strong></p>
  
  <p>The <strong>2nd</strong> and <strong>3rd</strong> methods give me this error:</p>
  
  <pre><code>Missing argument 2 for Illuminate\Database\Eloquent\Model::setAttribute(), called in /var/www/html/AppLaravel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php on line 525 and defined
  </code></pre>
  
  <p>I don't know what means this error, I have found a lot about it, and about to populate the data into the database manually, with no results.</p>
  
  <p>This is the model class:</p>
  
  <pre><code>namespace App;
  
  use Illuminate\Database\Eloquent\Model;
  
  class Car extends Model
  {
      const CREATED_AT = null;
      const UPDATED_AT = null;
      protected $fillable = ['brand', 'model'];
  }
  </code></pre>
  
  <p>This is the migration class:</p>
  
  <pre><code>use Illuminate\Support\Facades\Schema;
  use Illuminate\Database\Schema\Blueprint;
  use Illuminate\Database\Migrations\Migration;
  
  class CreateCarsTable extends Migration
  {
      /**
       * Run the migrations.
       *
       * @return void
       */
      public function up()
      {
          Schema::create('cars', function (Blueprint $table) {
              $table-&gt;increments('id');
              $table-&gt;string('brand');
              $table-&gt;text('model');
          });
      }
  
      /**
       * Reverse the migrations.
       *
       * @return void
       */
      public function down()
      {
          Schema::dropIfExists('cars');
      }
  }
  </code></pre>
  
  <h2>EDIT</h2>
  
  <p>I've tested with the bulk insertion too:</p>
  
  <p>4th</p>
  
  <pre><code>$arr = [
      [
          'brand' =&gt; 'Infinity',
          'model' =&gt; 'MS500',
      ],
      [
          'brand' =&gt; 'Toyota',
          'model' =&gt; 'LK2500',
      ],
  ];
  
  DB::insert($arr);
  </code></pre>
  
  <p>... but I got this new error:</p>
  
  <pre><code> ErrorException (E_NOTICE) Array to string conversion
  </code></pre>