increments('id'); $table->string('name'); $table->unsignedInteger('company_id')->nullable()->index(); $table->timestamps(); $table->softDeletes(); }); } if (!Schema::hasTable('calllogs_dict_source')) { Schema::create('calllogs_dict_source', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->unsignedInteger('company_id')->nullable()->index(); $table->timestamps(); $table->softDeletes(); }); } if (!Schema::hasTable('calllogs_dict_outcome')) { Schema::create('calllogs_dict_outcome', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->unsignedInteger('company_id')->nullable()->index(); $table->timestamps(); $table->softDeletes(); }); } // Seed default global values (company_id = null) only when the tables are empty. $now = now(); if (DB::table('calllogs_dict_status')->count() === 0) { $statuses = [ 'New', 'In Progress', 'Follow-Up Scheduled', 'Pending Response', 'Closed - Won', 'Closed - Lost', 'Not Interested', ]; DB::table('calllogs_dict_status')->insert( array_map(fn ($name) => ['name' => $name, 'company_id' => 1, 'created_at' => $now, 'updated_at' => $now], $statuses) ); } if (DB::table('calllogs_dict_source')->count() === 0) { $sources = [ 'Softphone', 'Campaign', 'Inbound Web', 'Referral', 'WhatsApp', 'Email', 'Manual', 'Other', ]; DB::table('calllogs_dict_source')->insert( array_map(fn ($name) => ['name' => $name, 'company_id' => 1, 'created_at' => $now, 'updated_at' => $now], $sources) ); } if (DB::table('calllogs_dict_outcome')->count() === 0) { $outcomes = [ 'Answered - Interested', 'Answered - Not Interested', 'Left Voicemail', 'No Answer', 'Callback Requested', 'Follow-Up Needed', 'Sale Closed', 'Other', ]; DB::table('calllogs_dict_outcome')->insert( array_map(fn ($name) => ['name' => $name, 'company_id' => 1, 'created_at' => $now, 'updated_at' => $now], $outcomes) ); } } public function down(): void { Schema::dropIfExists('calllogs_dict_outcome'); Schema::dropIfExists('calllogs_dict_source'); Schema::dropIfExists('calllogs_dict_status'); } };