I would like to extend the existing User model in Laravel 5.0 to add new columns to the table. How can I do so ?
php artisan make:migration users_disabled_column
where disabled is name of column you want to add to existed table.
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class UsersDisabledColumn extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function($table) {
$table->boolean('disabled')->default(false);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function($table) {
$table->dropColumn('disabled');
});
}
}
php artisan migrate
$user = User::find($id);
$user->disabled = false;
$user->save();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With