How to create one-to-one relationship in the database using Laravel

Framework
Laravel
Web Programming

How to create one-to-one relationship in the database using Laravel

Create one-to-one relationship in the database using Laravel Steps: 1. Create a migration file for adding a new table profile php artisan make:migration create_table_profile 2. Add the following code in the up function Schema::create(‘profiles’, function(Blueprint $table) { $table->increments(‘id’); $table->integer(‘user_id’)->unsigned(); $table->foreign(‘user_id’)->references(‘id’)->on(‘users’)->onDelete(‘cascade’); $table->string(‘telephone’); $table->timestamps(); }); 3. Run the migrate command php artisan migrate 4. Add User Model […]

Read More