Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable 'create_at' and 'update_at' in Laravel's seed file?

Tags:

People also ask

How to disable updated_ at and created_ at in Laravel?

By setting the class constant of UPDATED_AT to null on the models you wish to disable that column, Laravel will no longer attempt to set the column automatically.

How to disable timestamp in Laravel?

Update: You can also disable timestamps by removing $table->timestamps() from your migration.

How do I delete a seeder in Laravel?

use Undo Seeder for Laravel. When you install UndoSeeder, the following artisan commands are made available: db:seed-undo Undo seeds in the seeds directory. db:seed-refresh Undo seeds run seeds again.


I don't want to use rows 'update_at' and 'create_at', but Laravel's seed file is trying to update it. How can I disable it?

Here is the code that I'm using:

use Illuminate\Database\Migrations\Migration;

class SeedUsersTable extends Seeder {

// $timestamps = false;  <=== will return error
// public static $timestamps = false;  <=== will return error

    public function run()
    {
        DB::table('users')->delete();
        User::create(array(
                'id' => 1,
                'name' => 'Админ',
                'password' => Hash::make('admin'),
                'login' => 'admin'
        ));
    }
}