Turn Your Vehicle Into a Smart Earning Asset

While you’re not driving your car or bike, it can still be working for you. MOTOSHARE helps you earn passive income by connecting your vehicle with trusted renters in your city.

πŸš— You set the rental price
πŸ” Secure bookings with verified renters
πŸ“ Track your vehicle with GPS integration
πŸ’° Start earning within 48 hours

Join as a Partner Today

It’s simple, safe, and rewarding. Your vehicle. Your rules. Your earnings.

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

Part-1 Part-2

Now, we’ll create the 2nd table State to merge with the Country table.

Step 1. Create child file resources/views/State folder with name create.blade.php.

Step 2. Create edit.blade.php file. In this file within resources/views/State folder.

Step 3. Create an index.blade.php file within resource/views/State/ folder.

Step 4. Go to app/State.php. Now, we need to list all the properties we need in the $fillable array.

Step 5. Go to app/Http/Controllers/StateController.php file.

 ->leftJoin('countries', 'states.country_id', '=', 'countries.country_id')Code language: PHP (php)
 public function index()
    {
         $states = State::all()->toArray();
         $states = DB::table('states')
         ->leftJoin('countries', 'states.country_id', '=', 'countries.country_id')
         ->orderBy('state_id','desc')->paginate(5);
        return view('state.index',  ['states' => $states]);

    }Code language: PHP (php)

Step 6. Then, go to routes/web.php file and define all these routes.

Route::resource('state','StateController');
Route::any('/search1', 'StateController@search');Code language: PHP (php)

Run the URL

Thanks

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.