How to merge two or multiple tables to each other in the Laravel PHP Framework? (Part-1)

How to merge two or multiple tables to each other in the Laravel PHP Framework?

Part-2 Part-3

How to seed Country/State data into the Database? Click Here Here, we are going to merge the Country table to the State table using left join

The LEFT JOIN keyword returns all records from the left table (table1), and the matched records from the right table (table2). The result is NULL from the right side if there is no match.

Step 1. Create a new Project in Laravel, so open git bash. Write down the following command:-

Step 2. Create the authentication scaffolding and Country model. Write down the following command:-

Step 3. Create the State model. Write down the following command:-

Step 4. Generate a migration file into the database/migrations folder of the Country table.

Step 5. Generate a migration file into the database/migrations folder of State table.

Step 6. Migrate these tables into the MySQL database, so write the following command.

Step 7.  Create a CountryController in App/Http/Controller folder so, write the following command.

Step 8. Create a StateController in App/Http/Controller folder so, write the following command.

Step 9.  Create child file resources/views/Country folder with name create.blade.php

Step 10. Create an index.blade.php file within resource/views/Country/ folder.

Step 11. Create edit.blade.php file. In this file within resources/views/Country folder.

Thanks

Total Page Visits: 1195 - Today Page Visits: 1