$userSubjects * @property-read Collection $insights * @property-read Collection $insightSchedules * @property-read Collection $telegramUsers * @property-read Collection $tokenUsages * @property-read Collection $subjects */ class User extends Authenticatable { /** @use HasFactory<\Database\Factories\UserFactory> */ use HasFactory, Notifiable, HasRoles; /** @var array */ protected $fillable = [ 'name', 'email', 'password', 'phone', 'locale', 'is_active', 'is_approved', ]; /** @var array */ protected $casts = [ 'email_verified_at' => 'datetime', 'password' => 'hashed', 'is_active' => 'boolean', 'is_approved' => 'boolean', ]; /** @var array */ protected $hidden = [ 'password', 'remember_token', ]; /** * Get the user subjects for the user. */ public function userSubjects(): HasMany { return $this->hasMany(UserSubject::class); } /** * Get the insights for the user. */ public function insights(): HasMany { return $this->hasMany(Insight::class); } /** * Get the insight schedules for the user. */ public function insightSchedules(): HasMany { return $this->hasMany(InsightSchedule::class); } /** * Get the telegram users for the user. */ public function telegramUsers(): HasMany { return $this->hasMany(TelegramUser::class); } /** * Get the token usages for the user. */ public function tokenUsages(): HasMany { return $this->hasMany(TokenUsage::class); } /** * Get the subjects created by the user. */ public function subjects(): HasMany { return $this->hasMany(Subject::class); } } PHP; writeFile($basePath . '/app/Models/User.php', $userModel); // Create remaining migration files $migrations = [ '2026_08_03_115629_create_telegram_users_table.php' => <<<'PHP' id(); $table->foreignId('user_id')->constrained()->cascadeOnDelete(); $table->string('telegram_user_id')->unique(); $table->string('telegram_username')->nullable(); $table->string('telegram_first_name')->nullable(); $table->string('telegram_last_name')->nullable(); $table->boolean('is_active')->default(true); $table->timestamps(); }); } public function down(): void { Schema::dropIfExists('telegram_users'); } }; PHP, '2026_08_03_115630_create_token_usages_table.php' => <<<'PHP' id(); $table->foreignId('user_id')->constrained()->cascadeOnDelete(); $table->integer('input_tokens')->default(0); $table->integer('output_tokens')->default(0); $table->integer('total_tokens')->default(0); $table->string('model')->nullable(); $table->string('provider')->nullable(); $table->timestamps(); $table->index(['user_id', 'created_at']); }); } public function down(): void { Schema::dropIfExists('token_usages'); } }; PHP, '2026_08_03_115631_add_profile_fields_to_users_table.php' => <<<'PHP' string('phone')->nullable()->after('email'); $table->string('locale')->default('pt_BR')->after('phone'); $table->boolean('is_active')->default(true)->after('locale'); $table->boolean('is_approved')->default(false)->after('is_active'); }); } public function down(): void { Schema::table('users', function (Blueprint $table) { $table->dropColumn(['phone', 'locale', 'is_active', 'is_approved']); }); } }; PHP, ]; foreach ($migrations as $file => $content) { writeFile($basePath . '/database/migrations/' . $file, $content); } echo "All migration files created.\n";