// Source - https://stackoverflow.com/q/79812270
// Posted by Izedin Abaoli, modified by community. See post 'Timeline' for change history
// Retrieved 2025-11-07, License - CC BY-SA 4.0
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('employers', function (Blueprint $table) {
$table->id();
//$table->foreignIdFor(\App\Models\User::class);
$table->foreign('user_id')->references('id')->on('users');
$table->string('name');
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('employers');
}
};
I believe this is the way you should define foreign ids.