Category Archives: Laravel

Laravel Tutorials

Laravel Change Table or Column Name with Data Type Tutorial

In this Laravel Change Table or Column Name with Data Type Tutorial I will show you how change column name or change column type with laravel migration. In this article I will also show you how to rename column name in laravel migration. You will also learn how to change data type in laravel migration. In this example we will be using “doctrine/dbal” composer package.

Laravel Change Table or Column Name with Data Type Tutorial

In this step by step tutorial I will demonstrate you how to change column name or  how to change column data type in laravel migration.

Create Laravel Application

Create Model

Add the table values for migration in migrations/timestamp_create_students_table file:

Run laravel migration command:

Install DBAL Package

In this step we will install doctrine/dbal composer package. Please use the following command to install doctrine/dbal package.

Rename Laravel Column Name with Migration

In this example we will change column name “gender” to “subjects” so run command to create a new migration file:

Add the code in newly created rename_gender_in_students_table.php file:

Run the below command to change or rename the column value gender to subjects:

Update Data Type with Laravel Migration

Now we will change the data type using laravel migration.

How to Create Custom 404 Page in Laravel 8

n this How to Create Custom 404 Page in Laravel 8 tutorial I’ll show you how to create custom 404 error page in laravel. In this tutorial you will learn to create custom error page in laravel 8. In this step by step tutorial I’ll demonstrate the process to create custom 404 error page in laravel 8.

How to Create Custom 404 Page in Laravel 8

In this tutorial we will be creating custom error page for 404 error. Please Follow the instruction given below to create custom 404, 500 error pages in laravel:

Create New Laravel Project

First of all we need to create a fresh laravel project, download and install Laravel 8 using the below command

Create Custom 404 Error Page

In this step we will be creating custom 404 error page. Lets go to resources/views directory and create a folder named errors. Then inside the errors folder, we will create a file called 404.blade.php.

resources/views/errors/404.blade.php

To test out the 404 custom error template, you need to start the application.

Go to a wrong URL in the browser’s address bar.


Similarly you can create rest of the error handling blade views for 403, 500, 419, 255 and 405 exceptions.

Laravel 8 Create Multi Step Form using Livewire Wizard Form Package

In this Laravel 8 Create Multi Step Form using Livewire Wizard Form Package Tutorial I will show you how to create multi step form or form wizard using livewire package in laravel 8 application. In this tutorial we will learn to create multi step form or form wizard in laravel using livewire package. In this article we will be creating simple multi step form wizard with bootstrap wizard design using livewire package. In this tutorial you will also learn to install, setup and use laravel livewire form.

Laravel 8 Create Multi Step Form using Livewire Wizard Form Package

In this step by step livewire form wizard tutorial will guide you through how to create multi-step form or form wizard using livewire package in laravel 8. Please follow instruction given below:

Generate Laravel Project

First of all we need to create a fresh laravel project, download and install Laravel 8 using the below command

Connect with Database

Now, lets create a MySQL database and connect it with laravel application. After creating database we need to set database credential in application’s .env file.

Model and Migration

Now, in this step we will create model and migration file. Please run the following command:

Define table values in database/migrations/create_teams_table.php file:

Add the following code in the app/Models/Team.php file:

Now, run following command to migrate database schema.

Install Livewire Package

In this step, we will install livewire Package via the composer dependency manager. Use the following command to install livewire Package.

Create Livewire Component

In this step we will create a form wizard component using following artisan command:

The above command generated two files on the following path:


Open app/Http/Livewire/Wizard.php file and put the following code in it.

Next, open resources/views/livewire/wizard.blade.php file, add the following code:

Next, add custom styling in multi-step form. So create a public/multiform.css file and add the following code:

Create Form Route

After this, we need to define routes in “routes/web.php” file. Lets open “routes/web.php” file and add the following routes in it.

routes/web.php

Render Multi-step Form in Blade View

Add below code in resources/views/welcome.blade.php file:

Now we are ready to run our example so lets start the development server using following artisan command –

Now, open the following URL in browser to see the output –

Laravel 8 Livewire Image Upload Tutorial with Example

In this Laravel 8 Livewire Image Upload Tutorial I’ll show you how to upload Image with livewire package in laravel 8 application. In this tutorial you will learn to upload Image using livewire package in laravel. In this article I will share example to upload Image using livewire file upload component. Laravel livewire package makes uploading and saving image easy. With Laravel livewire package it is easy handle Image upload.

Laravel 8 Livewire Image Upload Tutorial with Example

In this step by step tutorial I will demonstrate you how to upload image using livewire in laravel application. Please follow the instruction given below:

Create Laravel Project

First of all we need to create a fresh laravel project, download and install Laravel 8 using the below command

Add Database Configurations

Now, lets create a MySQL database and connect it with laravel application. After creating database we need to set database credential in application’s .env file.

Create Model and Migration

Now, in this step we will create model and migration file. Please run the following command:

Open database/migrations/create_todos_table.php file, define the table values for uploading files:

Add the given properties inside the Model file as well within app/Models/Todo.php file:

Now, run the migration to create database table using following artisan command:

Install Livewire Package

In this step, we will install livewire Package via the composer dependency manager. Use the following command to install livewire Package.

Create Livewire Component

In this step we will create a livewire image upload component using following command:

There are two files have been generated on the given paths:


Add the following code in app/Http/Livewire/UploadFile.php config file:

Add the following code in resources/views/livewire/upload-file.blade.php config file:

Define Route

After this, we need to define routes in “routes/web.php” file. Lets open “routes/web.php” file and add the following routes in it.

routes/web.php

Create Blade View

In this step we will create a blade view file to upload image file. Go to resources/views/welcome.blade.php file similarly add the following code:

Now we are ready to run our example so lets start the development server using following artisan command –

Now, open the following URL in browser to see the output –

Create Laravel 8 Dynamic Image Slider with Vue Component using Owl Carousel Plugin

In this Create Laravel 8 Dynamic Image Slider with Vue Component using Owl Carousel Plugin tutorial, I’ll show you how to implement Owl carousel slider with Vue Js in laravel 8. In this tutorial you will learn to create Owl carousel slider with Vue Js in laravel 8. With Owl carousel you can create image slider in laravel project.

In this step by step tutorial I will demonstrate you how to implement Owl carousel slider with Vue Js in laravel 8. Please follow the instruction given below:

Create Laravel Application

First of all we need to create a fresh laravel project, download and install Laravel 8 using the below command

Adding Database Details

Now, lets create a MySQL database and connect it with laravel application. After creating database we need to set database credential in application’s .env file.

Setting Up Model & Migration

Now, in this step we will create model and migration file. Please run the following command:

Place the below code in app/Models/Post.php file:

Add code in database/migrations/create_posts_table.php:

Now, run the migration to create database table using following artisan command:

Install Vue Dependencies

In this step we will install Vue dependencies using following commands:

Install vue owl carousel package in Laravel app:


Run command to compile your fresh scaffolding:

Adding Dummy/Fake Images Data

Now we will add some dummy image data in post model

Put the below code in database\factories\PostFactory.php:

Run command to enter into tinker shell:


Next, define the Post model name with the factory() method and generate test data:

Generate & Set Up Controller

Now, lets create a controller named CarouselController using command given below –

Add code in app\Http\Controllers\CarouselController.php file:

Create Routes

After this, we need to define routes in “routes/web.php” file. Lets open “routes/web.php” file and add the following routes in it.

routes/web.php

Go to resources/js/components/ExampleComponent.vue file put the below code within:

You can check out the vue slider component configurations on the resources/js/app.js file:

Create Laravel Blade View

Now we will create app.blade.php view file and put inside the resources/views/layout folder, also paste the below code within:

Go to resources/views/welcome.blade.php file and paste the following code to call the vue carousel slider component in laravel blade view:

Thereafter, you have to open the console and run the node development server:

Now we are ready to run our example so lets start the development server using following artisan command –

Now, open the following URL in browser to see the output –

Create Authentication Scaffolding in Laravel 8 with Breeze

In this Create Authentication Scaffolding in Laravel 8 with Breeze tutorial I will show how to create authentication scaffolding in laravel 8 application using breeze. In this tutorial you will learn to install and use breeze authentication to generate authentication scaffolding in laravel 8. In this example we will be using breeze authentication to implement user authentication scaffolding in laravel application. The breeze auth will be used to create login, register, reset the password, forget password, email verification, and two-factor authentication blade views and controller file.

Create Authentication Scaffolding in Laravel 8 with Breeze

Here are the list of auth pages or controller you can create with Laravel breeze:

  • Login/Sign-in
  • Register/Sing-up
  • Logout/Sign-out
  • Forget password
  • Reset password
  • Email verification
  • Two-factor authentication
  • Profile

Laravel Breeze Package Integration Example

In this step by step tutorial I will demonstrate you with example to implement user authentication scaffolding using breeze authentication in laravel 8 application. Please follow instruction given below:

  • Create Laravel 8 project
  • Add Database in Laravel
  • Install breeze scaffolding library
  • Run migration
  • Install Required NPM modules
  • Run Laravel application

Create Laravel project

First of all we need to create a fresh laravel project, download and install Laravel 8 using the below command

Add Database in Laravel

Now, lets create a MySQL database and connect it with laravel application. After creating database we need to set database credential in application’s .env file.

Install Breeze Scaffolding Plugin

In this step, we will install breeze auth Package via the composer dependency manager. Use the following command to install breeze auth Package.

Now you have to install laravel breeze for simple auth scaffolding. so let’s run bellow command:

Run Migration in Laravel

Now, run the migration to create database table using following artisan command:

Install Required NPM Modules

Now run following command to install node js and npm dependencies:

Then type the following command on cmd to run npm:

Run Laravel application

Now we are ready to run our example so lets start the development server using following artisan command –

Now, open the following URL in browser to see the output –

Create Live Search in Laravel 8 Vue JS App

In this Create Live Search in Laravel 8 Vue JS App Tutorial I will show you how to create live search in laravel 8 Vue Js application. In this tutorial you will learn to create live search in laravel vue js application. In this article I will share example to create a dynamic live search in Laravel with Vue Js. In this tutorial we will create a dynamic live search autocomplete which will fetch options from database table In Vue Js laravel application .

Create Live Search in Laravel 8 Vue JS App

In this step by step tutorial I will demonstrate you with example how to create live search in laravel 8 Vue Js application. Please follow the instruction given below:

Create Laravel Project

First of all we need to create a fresh laravel project, download and install Laravel 8 using the below command

Connecting Database

Now, lets create a MySQL database and connect it with laravel application. After creating database we need to set database credential in application’s .env file.

Set Up Model and Run Migration

Now, in this step we will create model and migration file. Please run the following command:

Put code in app/Models/Book.php:

You need to define the table values in migration file in database/migrations/create_books_table.php:

Now, run the migration to create database table using following artisan command:

Install Vue UI in Laravel

In this step we will install laravel UI using following command.

Install Vue js components with the help of node package manager command:


Run command to install scaffolding:

Adding Test Data with Faker

Now, run following command to add some dummy data.

Define faker function in database\factories\BookFactory.php file:

Run factory tinker command:


Once entered into Psy shell then generate the dummy data:

Create Controller

Now, lets create a controller named BookController using command given below –

Once the above command executed, it will create a controller file BookController.php in app/Http/Controllers/ directory. Open the BookController.php file and put the following code in it.

app/Http/Controllers/BookController.php

Add Routes

After this, we need to define routes in “routes/web.php” file. Lets open “routes/web.php” file and add the following routes in it.

routes/web.php

Build Laravel Vue Component

Now, go to resources/js/components/ folder, and create AutocompleteComponent.vue file.

Then update resources/js/components/AutocompleteComponent.vue file to define Vue Js autocomplete component.

Next, define the Vue component in resources/js/app.js:

Finally, define the vue component in resources/views/welcome.blade.php to display the autocomplete component:

Go to resources/views/ directory create layout directory, also build a app.blade.php file. Then put the following code in resources/views/layout/app.blade.php:

Thereafter, you have to open the console and run the node development server:

Run Development Server

Now we are ready to run our example so lets start the development server using following artisan command –

Now, open the following URL in browser to see the output –

How to Display Events in Calendar with Laravel 8 Vue JS App

In this How to Display Events in Calendar with Laravel 8 Vue JS App tutorial I’ll show you how to display events on the calendar using vue js fullcalendar components in laravel 8 apps. In this tutorial you will learn to display events on the calendar using vue js fullcalendar in laravel 8. This tutorial you will also learn to show dynamic event data on vue js calendar using Vue full calendar components in laravel vue js.

How to Display Events in Calendar with Laravel 8 Vue JS App

In this step by step tutorial I will demonstrate you how to display events on the calendar using vue js fullcalendar components in laravel 8 applications. Please follow the instruction given below:

  • Create Laravel project
  • Make database connection
  • Generate and configure model, also migration
  • Vue Full calendar plugin configuration in laravel
  • Create routes
  • Generate and configure the controller
  • Create and set up Vue component
  • Connect laravel and Vue with blade view
  • Start the laravel development server

Create Laravel Project

First of all we need to create a fresh laravel project, download and install Laravel 8 using the below command

Make Database Connection

Now, lets create a MySQL database and connect it with laravel application. After creating database we need to set database credential in application’s .env file.

Configure Model and Run Migration

Now, in this step we will create model and migration file. Please run the following command:

Now put the following code in app/Models/EventList.php file:

app/Models/EventList.php

Add values which are to be migrated in database within database/migrations/create_event_lists_table.php:

Now, run the migration to create database table using following artisan command:

Install Full Calendar and NPM Packages

In this step we will install laravel ui using following command:

Use command to install Vue components in laravel:


Next, up you have to install fullcalendar and dependent packages for it:


Run npm command to compile scaffolding:

Create Calendar Controller

Now, lets create a controller named CalendarController using command given below –

Put the following code in app\Http\Controllers\CalendarController.php file:

app\Http\Controllers\CalendarController.php

Create Routes

After this, we need to define routes in “routes/web.php” file. Lets open “routes/web.php” file and add the following routes in it.

routes/web.php

Setting up Vue Component

Now go to resources/js/components/ directory and create CalendarComponent.vue template file. Then you need to update the resources/js/components/CalendarComponent.vue file with below code:

Next, import full calendar, also define the Vue component within resources/js/app.js file:

Add the vue component directive within resources/views/welcome.blade.php file to show the full calendar in view:

Now go to resources/views/ folder create a layout folder similarly create a app.blade.php file. Then add the below code in resources/views/layout/app.blade.php

Now test out what we have built so far, so start the npm:

Now we are ready to run our example so lets start the development server using following artisan command –

Now, open the following URL in browser to see the output –

Laravel 8 Vue JS File/Image Upload Example Tutorial

In this Laravel 8 Vue JS Image file Upload Example Tutorial, we will learn how to upload a image file in Laravel 8 Vue JS application. In this tutorial you will learn to how to upload a image file in Laravel 8 Vue JS application.  In this article I’ll guide through how to upload files with Vue js using Axios post request In Laravel 8 Vue JS application. In this tutorial, we will be creating a simple form to send form data (files, images, input fields etc) with Vue js using Axios to send POST request in laravel.

Laravel 8 Laravel 8 Vue JS File/Image Upload Example Tutorial

In this step by step tutorial I will demonstrate you how to upload image files with Vue js using In Laravel 8 Vue JS application. Please follow the instruction given below:

Install Laravel App

First of all we need to create a fresh laravel project, download and install Laravel 8 using the below command

Connecting to Database

First of all we need to create a fresh laravel project, download and install Laravel 8 using the below command

Model and Migration

Now, in this step we will create model and migration file. Please run the following command:

Define code in database/migrations/create_file_uploads_table.php:

Add code as given below in app/Models/FileUpload.php:

Now, run the migration to create database table using following artisan command:

Install Laravel Vue UI and NPM Dependencies

Use command to install Vue components:


Next, install run below command to compile scaffolding:

Create Controller

Now, lets create a controller named FileController using command given below –

Once the above command executed, it will create a controller file FileController.php in app/Http/Controllers/ directory. Open the FileController.php file and put the following code in it.

app/Http/Controllers/FileController.php

Create Routes

After this, we need to define routes in “routes/web.php” file. Lets open “routes/web.php” file and add the following routes in it.

routes/web.php

Set Up Vue Component

Now, go to resources/js/components/ directory, inside here create FileUploadComponent.vue file. Then add the following code in resources/js/components/FileUploadComponent.vue:

Then, register the Vue component inside the resources/js/app.js:

Now, go to resources/views/ folder and create layout directory and app.blade.php file. Then add the following code in resources/views/layout/app.blade.php:

Next you have to place the vue file upload component in resources/views/welcome.blade.php file:

Ultimately, you have to open the console and run the node development server:

Now we are ready to run our example so lets start the development server using following artisan command –

Now, open the following URL in browser to see the output –

How to Build Laravel 8 Vue JS Like Dislike System

In this How to Build Laravel 8 Vue JS Like Dislike System Tutorial I’ll show you how to create Like Dislike system with Vue Js in laravel 8. In this tutorial you will learn to create Like Dislike system with Vue Js in laravel 8. In this article we will create example to create Like Dislike system with Vue Js in laravel 8.

How to Build Laravel 8 Vue JS Like Dislike System

In this step by step tutorial I will demonstrate you with example how to create Like Dislike system with Vue Js in laravel 8. Please follow the step given below:

Create Laravel Project

First of all we need to create a fresh laravel project, download and install Laravel 8 using the below command

Connect Database

Now, lets create a MySQL database and connect it with laravel application. After creating database we need to set database credential in application’s .env file.

Set Up Model and Run Migration

Now, in this step we will create model and migration file. Please run the following command:

Put the following code in database/migrations/create_blogs_table.php file:

database/migrations/create_blogs_table.php

Place the below code in app/Models/Blog.php:

Now, run the migration to create database table using following artisan command:

Generate Fake Data

In this step we will add some dummy records into blog model.

Add following code in database\factories\BlogFactory.php:

Execute tinker command in console:


Above command will take you inside the Psy shell, then run the below command:

Install Vue UI and NPM Dependencies

Run the following commands to install laravel Vue UI and NPM dependencies.

After this run the below command to install npm packages:

Build New Controller

Now, lets create a controller named BlogController using command given below –

Once the above command executed, it will create a controller file BlogController.php in app/Http/Controllers/ directory. Open the BlogController.php file and put the following code in it.

app/Http/Controllers/BlogController.php

Create Routes

After this, we need to define routes in “routes/web.php” file. Lets open “routes/web.php” file and add the following routes in it.

routes/web.php

Create Like Dislike Vue Components

Add below code in resources/js/components/LikeComponent.vue file:

Place the code in resources/js/components/DislikeComponent.vue file:

Now, register like and dislike vue components in resources/js/app.js file:

Setting Up Vue Component in Blade View

Now, you have to create a blog.blade.php file in the resources/views/ folder, add the following code in the resources/views/blog.blade.php file:

Now we will create a blog-details.blade.php file in the resources/views/ folder, and put the following code in resources/views/blog-details.blade.php file:

Now we will create layout folder in resources/views/ directory, also create app.blade.php file and then add the below code in resources/views/layout/app.blade.php file:

Run Like Dislike System

Open terminal and execute the following command:

Now we are ready to run our example so lets start the development server using following artisan command –

Now, open the following URL in browser to see the output –

How to Restrict or Block User Access via IP Address in Laravel 8

In this How to Restrict or Block User Access via IP Address in Laravel 8 tutorial, I’ll show you how to restrict or block user via IP address from accessing the website in laravel. In this tutorial you will learn to restrict or block user to access website using IP Address in laravel. With this you will be able to restrict or block user via IP address from accessing the website, In this step by step tutorial we will be creating a middleware to restrict user with IP Address in laravel.

How to Restrict or Block User Access via IP Address in Laravel 8

In this step by step tutorial I will demonstrate you with example on how to restrict or block user via IP address from accessing the website in laravel. Please follow the instruction given below:

Create Laravel Application

First of all we need to create a fresh laravel project, download and install Laravel 8 using the below command

Database Connection

Now, lets create a MySQL database and connect it with laravel application. After creating database we need to set database credential in application’s .env file.

Create Block IP Middleware

In this step we will create a custom middleware to restrict users via ip address. Run following command to create a middleware named class BlockIpMiddleware:

Then, go to app/Http/Middleware/RestrictIpAddressMiddleware.php configuration file and replace the entire code with the following code:

Add Middleware in Kernel

Now, we have to define the RestrictIpAddressMiddleware class in the $middlewareGroups array within the app/Http/Kernel.php file:

How to Get Location Information with IP Address in Laravel 8

In this How to Get Location Information with IP Address in Laravel 8 tutorial I will show you how to get user location information using IP address in laravel 8. In this tutorial you will learn to get user’s country name, country code, city name, and address from user IP address in laravel 8. In this example I will help you to fetch user location data from IP address. We will be using stevebauman/location package in this example to fetch country name, country code, city name, and address from IP address.

The stevebauman/location laravel package is used to get users location data by their IP Address. This helps in retrieving user’s location information from IP address. The location library helps in retrieving following location information:

  • Country name and code
  • Region name and code
  • City name
  • Zipcode
  • ISO code
  • Postal code
  • Latitude and longitude
  • Metro code

How to Get Location Information with IP Address in Laravel 8

In this tutorial you will learn how to get current user location with ip address using stevebauman location package. Please follow the instruction given below:

Create Laravel Project

First of all we need to create a fresh laravel project, download and install Laravel 8 using the below command

Make Database Connection

Now, lets create a MySQL database and connect it with laravel application. After creating database we need to set database credential in application’s .env file.

Install Location Package

In this step, we will install stevebauman/location Package via the composer dependency manager. Use the following command to install stevebauman/location Package.

Register Location Package

Then, Go to config directory and open app.php file. And register this package into laravel 8 app by adding the following code into your app.php file:

In response to the above question choose following provider from the options list using a number prefix:



You can also check on the config/location.php path.

Generate and Setting Up Controller

Now, lets create a controller named UserController using command given below –

Once the above command executed, it will create a controller file LocationController.php in app/Http/Controllers/ directory. Open the LocationController.php file and put the following code in it.

app/Http/Controllers/LocationController.php

Build Routes

After this, we need to define routes in “routes/web.php” file. Lets open “routes/web.php” file and add the following routes in it.

routes/web.php

Run Development Server

Now we are ready to run our example so lets start the development server using following artisan command –

Now, open the following URL in browser to see the output –