1👍
✅
You should add a reference for company_id
and onDelete(cascade)
in your migration See this link What does onDelete('cascade') mean?, When you delete a company, It will delete all the employees associated with that company automatically.
public function up() {
Schema::create('employees', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('BadgeCode')->unique();
$table->bigInteger('company_id')->unsigned();
$table->foreign('company_id')->references('id')->on('companies')->onDelete('cascade');
$table->timestamps();
});
}
Source:stackexchange.com