Level 55
$table->foreignId('role_id')->default(3)->constrained('roles');
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have a users and roles table ...during the user registration process I want to set the foreign id to default 3
$table->foreignId('role_id')->constrained('roles');
how can i set this foreign id to default value 3
$table->foreignId('role_id')->default(3)->constrained('roles');
Please or to participate in this conversation.