How to fetch data from multiple tables in laravel

Step 1: Download Laravel Framework

For download fresh copy of Laravel framework, so first we have to into command prompt and run following command. This command will make join_table directory and under that directory it will download Laravel framework latest version.

composer create-project --prefer-dist laravel/laravel join_table "5.8.*"

Step 2: Make Database connection

After download and install Laravel framework and after this we want to make first database connection. So for make database connection, we have to open .env file and under this file, we have to define mysql database configuration. So it will create database connection in Laravel framework.


Step3: Sql file import

Once you have make database connection, then after we have to make table in mysql database. So for this you have to run following sql script in your local database, so it will create table in your define mysql database.

Step3: Create Model Class

In Laravel framework, we have to create model class for database related operation. So for create model classe using compost, we have go to command prompt and run following command, this command will make model class file with name Country.php under app/Models folder.

php artisan make:model Country

After create model class, we have to open that file and under that file we have to define mysql table name details and column details.

Step4:Create Controller Class

Under this Laravel framework, for handle HTTP request we have to create controller class. So for create controller using compost, we have go to command prompt and run following command.

php artisan make:controller JointableController

Once your controller class has been create then for open that file, we have go to app/Http/Controllers/JointableController.php file and under this file you have write following code for join multiple table using eloquent model and fetch data from multiple table in single query execution.

Step4: Create View Blade file

For display HTML output in browser, so we have to create view blade file in Laravel framework. In Laravel framework view blade file has been store under resources/views folder. Under this file, we have create join_table.blade.php file. Under this file, it will received data from controller class file. You can find source code of this view blade file in below.

Step 5: Set Route

Under this Laravel framework, we have to set route of the controller method. For set route in Laravel 8 framework, we have to open routes/web.php file. In Laravel 8 framework for set route, we have to first import our controller class under this web.php file. And for set route you can find source code below.

Step 6: Run Laravel Server

After follow all above steps now all are set now we want to run Laravel application in browser. So for this, we have to go command prompt and run following command.

php artisan serve

Once you have run above command so after run this command it will provide us base url of our Laravel application. So for check above script output, we have to hit following url in browser.

Tagged :

How to fix fatal error: Maximum execution time of 300 seconds exceeded in XAMPP

Step1: Go to this path C:\xampp\phpMyAdmin\libraries

Step2: open file config.default.php

Step3: config.default.php on this line $cfg[‘ExecTimeLimit’] = 300; change

Step4: config.default.php on this line $cfg[‘ExecTimeLimit’] = 0; change

Step5: XAMPP Will be Restart and Import the Sql file.

Tagged : /

How to create new microservices in Laravel framework

Step1- Open command prompt or Git Bash on xampp/htdocs directory

Step2- Create Laravel New Project write this command

composer create-project –prefer-dist laravel/laravel scmgalaxy “5.5.*”

Step3- Move to project directory on git bash

cd scmgalaxy

Step4- Project directory on git bash on this command

composer require laravel/passport

Step5- Create Database in Mysql Server

Step5- Set Mysql Server Username ,Password and Database Name in .env file


Step6-scmgalaxy\app\user.php add in user model this code

use Laravel\Passport\HasApiTokens; use HasApiTokens, Notifiable;

Step8- scmgalaxy\app\Providers\AppServiceProvider add in this code

use Laravel\Passport\Passport;

Step8- config\auth.php add in this code

‘api’ => [ ‘driver’ => ‘passport’, ‘provider’ => ‘users’, ],

Step9- scmgalaxy\app\Http\Kernel.php add this code

‘client_credentials’ => \Laravel\Passport\Http\Middleware\CheckClientCredentials::class,

Step9- scmgalaxy\config\app.php add this code


Step10- Project directory on git bash on this command

composer update

Step11- Project directory on git bash on this command

php artisan make:auth

Step12- Project directory on git bash on this command

php artisan migrate

Step13- Project directory on git bash on this command

php artisan passport:install