Day: December 30, 2018

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
Framework
Laravel

How to create one-to-many relation in database using Laravel

Applying one-to-many relationship in the database using Laravel Steps 1. Create a migration file for adding a new table students php artisan make:migration create_table_students 2. Add the following code in the up function Schema::create(‘students’, function(Blueprint $table) { $table->integer(‘id’)->primary(); $table->string(‘name’); $table->text(’email’); $table->string(‘course’); $table->boolean(‘done’)->default(false); $table->timestamps(); }); 3. Create a migration file for adding a new table subjects […]

Read More