mardi 4 décembre 2018

laravel updated_at default null and on update current timstamp migration

here I want to do when the row is created the updated_at column should be null and when the row will get updated the column should be filled with current timestamp

Schema::create('city', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name')->unique();
        $table->enum('visibilty', ['Visible', 'Invisible'])->default('Invisible');
        $table->string('created_by')->nullable();
        $table->softDeletes();
        $table->dateTime('created_at')->default(\DB::raw('DATETIME'));
        $table->timestamp('updated_at')->default(\DB::raw('CURRENT_TIMESTAMP'));
    });



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2zKCMXl
via IFTTT

Aucun commentaire:

Enregistrer un commentaire