Add plan column to users table
MODIFY
app/Models/User.php
app/Models/User.php
@@ -14,13 +14,18 @@ class User extends Authenticatable
'email',
'password',
'verification_token',
- 'last_verification_mail_sent_at'
+ 'last_verification_mail_sent_at',
+ 'plan'
];
protected $hidden = [
'password', 'remember_token',
];
+ protected $attributes = [
+ 'plan' => 'standard'
+ ];
+
// Accessors
public function getAvatarAttribute($avatar)
{

ADD
database/migrations/2020_07_25_130850_add_plan_column_to_users_table.php
+<?php
+
+use App\Models\User;
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddPlanColumnToUsersTable extends Migration
+{
+ public function up(): void
+ {
+ Schema::table('users', function (Blueprint $table) {
+ $table->string('plan')->after('remember_token');
+ });
+
+ foreach (User::all() as $user) {
+ $user->update(['plan' => 'standard']);
+ }
+ }
+
+ public function down(): void
+ {
+ Schema::table('users', function (Blueprint $table) {
+ $table->dropColumn('plan');
+ });
+ }
+}

Add plan column to users table