PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, March 18, 2022

[FIXED] Laravel Seeder Does Not Work

 March 18, 2022     laravel, laravel-5, laravel-5.4, php     No comments   

Issue

I am using Laravel 5.4.

When I first created a project, I did migration and seeding and all worked fine.

Now I deleted the database and wanted to redo migration and seeding again, migration worked, but seeder does not.

When I entered this command:

php artisan db:seed

the result I got was:

Seeding: xxxTableSeeder

No error, no result was seed. And I should have 4 tables to be seeded but none of it being seeded.

I tried

composer dump-autoload

but not working as well.

DatabaseSeeder.php

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
/**
 * Run the database seeds.
 *
 * @return void
 */
public function run()
{
    $this->call(ATableSeeder::class);
    $this->call(BTableSeeder::class);
    $this->call(CTableSeeder::class);
    $this->call(DTableSeeder::class);
}
}

ATableSeeder.php

use Illuminate\Database\Seeder;

class ATableSeeder extends Seeder
{
/**
 * Run the database seeds.
 *
 * @return void
 */
public function run()
{
    DB::table('A')->insert([
        'username' => '',
        'firstname' => '',
        'lastname' => '',
        'email' => '',
        'contact' => '',
        'password' =>,
        'created_at' => date('Y-m-d H:i:s'),
        'updated_at' => date('Y-m-d H:i:s'),
    ]);
}
}

Any idea why?


Solution

It was the 'timezone' in config/app.php caused the issue. When I first migrated with the default timezone, which is 'UTC', everything works fine. Then I changed the timezone to 'UTC+8', and created_at and updated_at are working fine too. Then here comes the problem. I did migration again with the timezone 'UTC+8' and then stuck at the seeding part.

So now I changed the timezone to 'Asia/Kuala_Lumpur', everything is working perfectly fine!

Thank you guys!



Answered By - hahahaha
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing