Some Laravel seeders not doing anything - no errors, but no data inserted into table

627 Views Asked by At

So I have five seeds in my application - four of them seed no problem, the fifth one inserts no data into the database, but does not return any errors. Format is identical to the other seeders so I am not sure what this could be. Here is the code:

DatabaseSeeder.php

<?php

use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;

class DatabaseSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $this->call(RoleSeeder::class);
        $this->call(UserSeeder::class);
        $this->call(DomainSeeder::class);
        $this->call(SiteSeeder::class);
        $this->call(SyncSeeder::class);
    }
}

SyncSeeder.php (working example)

<?php

use Illuminate\Database\Seeder;
use App\Sync;

class SyncSeeder extends Seeder{

    public function run(){
        DB::table('sites')->delete();

        Sync::create(array(
            'synced_at'       => 0,
        ));
    }
}

SiteSeeder.php (not working)

<?php

use Illuminate\Database\Seeder;
use App\Site;

class SiteSeeder extends Seeder{

    public function run(){
        DB::table('sites')->delete();

        Site::create(array(
            'site_name'     => '...',
            'description'   => '...,
            'connection_id' => '...',
            'host'          => '...',
            'port'          => '...',
            'database_name' => '...',
            'username'      => '...',
            'password'      => '...'
        ));

        Site::create(array(
            'site_name'     => '...',
            'description'   => '...',
            'connection_id' => '...',
            'host'          => '...',
            'port'          => '...',
            'database_name' => '...',
            'username'      => '...',
            'password'      => '...'
        ));

    }
}

Any tips on debugging are greatly appreciated!

1

There are 1 best solutions below

0
On

Can you try without this part of code?

DB::table('sites')->delete();