Laravel Starter - PHP User Group (Myanmar)
Laravel Starter - PHP User Group (Myanmar)
Laravel Starter - PHP User Group (Myanmar)
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>Laravel</strong> <strong>Starter</strong><br />
Let's go ahead and look at what our create_users_table migration should look like:<br />
classCreate_<strong>User</strong>s_Table<br />
{<br />
}<br />
/**<br />
* Make changes to the database.<br />
*<br />
* @return void<br />
*/<br />
public function up()<br />
{<br />
Schema::table('users', function($table)<br />
{<br />
$table->create();<br />
}<br />
$table->increments('id');<br />
$table->string('email');<br />
$table->string('real_name');<br />
$table->string('password');<br />
$table->timestamps();<br />
});<br />
/**<br />
* Revert the changes to the database.<br />
*<br />
* @return void<br />
*/<br />
public function down()<br />
{<br />
Schema::drop('users');<br />
}<br />
Let's first discuss our up() method. Our goal is to create the users table and to define the<br />
fields within it. In order to accomplish this goal, we'll use the <strong>Laravel</strong> Schema class. When<br />
creating or making modifications to tables, we use the Schema class' table() method.<br />
9