id(); $table->foreignId('company_id')->constrained()->cascadeOnDelete(); $table->foreignId('manager_id')->nullable()->constrained('company_user')->nullOnDelete(); $table->foreignId('parent_id')->nullable()->constrained('departments')->nullOnDelete(); $table->string('name'); $table->text('description')->nullable(); $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete(); $table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete(); $table->timestamps(); $table->unique(['company_id', 'name']); }); } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists('departments'); } };