Skip to content

Blueprint foreignIdFor should add foreign key constraint #45707

Closed Answered by anilkumarthakur60
tavsec asked this question in Ideas
Discussion options

You must be logged in to vote
public function up()
{
    Schema::create('products', function (Blueprint $table) {
        $table->id();
        $table->string('name');
        $table->foreignIdFor(\App\Models\Manufacturer::class)->constrained()
    });
}

just adding constrained method can resolve your problem

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by tavsec
Comment options

You must be logged in to vote
1 reply
@anilkumarthakur60
Comment options

Comment options

You must be logged in to vote
2 replies
@Sophist-UK
Comment options

@Khant-Nyar
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
5 participants