Skip to content

Instantly share code, notes, and snippets.

@earth774
Created April 27, 2019 07:45
Show Gist options
  • Save earth774/68becfce4bd95f9573f7ee32b19914e5 to your computer and use it in GitHub Desktop.
Save earth774/68becfce4bd95f9573f7ee32b19914e5 to your computer and use it in GitHub Desktop.
create insert database
<?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->bigIncrements('id');
$table->string('fullname');
$table->string('lastname');
$table->string('age');
$table->string('tel');
$table->timestamps();
});
// User table
DB::table('users')->insert(
[[
'fullname' => 'สุทธิพงศ์',
'lastname' => 'นวลมะ',
'age' => '24',
'tel' => '088 323 4312',
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
]]
);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment