Xử lý định dạng date người dùng đưa fomat m/d/Y ghi vào db là Y-m-d như nào? (ok)

https://www.itsolutionstuff.com/post/laravel-9-eloquent-mutators-and-accessors-exampleexample.html

C:\xampp\htdocs\test\database\migrations\2014_10_12_000000_create_users_table.php

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateUsersTable extends Migration {
  /**
   * Run the migrations.
   *
   * @return void
   */
  public function up() {
    Schema::create('users', function (Blueprint $table) {
      $table->id();
      $table->string('name');
      $table->string('email')->unique();
      $table->timestamp('email_verified_at')->nullable();
      $table->string('password');
      $table->rememberToken();
      $table->date('date_of_birth');
      $table->timestamps();
    });
  }
  /**
   * Reverse the migrations.
   *
   * @return void
   */
  public function down() {
    Schema::dropIfExists('users');
  }
}

C:\xampp\htdocs\test\app\Models\User.php

C:\xampp\htdocs\test\app\Http\Controllers\UserController.php

C:\xampp\htdocs\test\routes\web.php

Last updated

Was this helpful?