<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Sanjay Kumar</title>
    <description>The latest articles on Forem by Sanjay Kumar (@webtutor).</description>
    <link>https://forem.com/webtutor</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1138641%2Fa4892fb3-03ad-4053-b7e2-8e7fe54d4c30.png</url>
      <title>Forem: Sanjay Kumar</title>
      <link>https://forem.com/webtutor</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/webtutor"/>
    <language>en</language>
    <item>
      <title>Laravel 10 How To Delete Data by Ajax Request Tutorial</title>
      <dc:creator>Sanjay Kumar</dc:creator>
      <pubDate>Sun, 01 Oct 2023 03:54:22 +0000</pubDate>
      <link>https://forem.com/webtutor/laravel-10-how-to-delete-data-by-ajax-request-tutorial-43g0</link>
      <guid>https://forem.com/webtutor/laravel-10-how-to-delete-data-by-ajax-request-tutorial-43g0</guid>
      <description>&lt;p&gt;Using AJAX queries to delete data is simple and efficient in Laravel 10, a powerful PHP framework. This tutorial will show you how to remove data in Laravel 10 using AJAX requests.&lt;/p&gt;

&lt;p&gt;We'll look at how to set up AJAX-based data deletion in Laravel 10, as well as how to use it in practise with real-world scenarios, throughout this article. By using ajax based concept you can also &lt;a href="https://onlinewebtutorblog.com/laravel-10-get-data-by-ajax-request/"&gt;get data from database&lt;/a&gt; in a very easier way.&lt;/p&gt;

&lt;h2&gt;
  
  
  Laravel Installation
&lt;/h2&gt;

&lt;p&gt;Open terminal and run this command to create a laravel project.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;composer create-project laravel/laravel myblog&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It will create a project folder with name myblog inside your local system.&lt;/p&gt;

&lt;p&gt;To start the development server of laravel –&lt;/p&gt;

&lt;p&gt;&lt;code&gt;php artisan serve&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;URL: &lt;a href="http://127.0.0.1:8000"&gt;http://127.0.0.1:8000&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup Data Controller
&lt;/h2&gt;

&lt;p&gt;You need to create a controller file,&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ php artisan make:controller UserController&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It will create a file &lt;strong&gt;UserController.php&lt;/strong&gt; inside &lt;strong&gt;/app/Http/Controllers&lt;/strong&gt; folder.&lt;/p&gt;

&lt;p&gt;Open file and write this complete code into it,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\User;
use Illuminate\View\View;

class UserController extends Controller
{
    public function index(): View
    {
        $users = User::paginate(10);

        return view('users', compact('users'));
    }

    public function delete($id)
    {
        User::find($id)-&amp;gt;delete();

        return response()-&amp;gt;json(['success' =&amp;gt; 'User Deleted Successfully!']);
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Create Blade Template File
&lt;/h2&gt;

&lt;p&gt;Go to &lt;strong&gt;/resources/views&lt;/strong&gt; folder and create a file with name &lt;strong&gt;users.blade.php&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Open file and write this complete code into it,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;

&amp;lt;head&amp;gt;
    &amp;lt;title&amp;gt;Laravel 10 How To Delete Data by Ajax Request Tutorial&amp;lt;/title&amp;gt;
    &amp;lt;link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.0.1/css/bootstrap.min.css" rel="stylesheet"&amp;gt;
    &amp;lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;meta name="csrf-token" content="{{ csrf_token() }}"&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;

    &amp;lt;div class="container" style="margin-top: 10px;"&amp;gt;

        &amp;lt;h3 style="text-align: center;"&amp;gt;Laravel 10 How To Delete Data by Ajax Request Tutorial&amp;lt;/h3&amp;gt;

        &amp;lt;table class="table table-bordered data-table" style="margin-top: 30px;"&amp;gt;
            &amp;lt;thead&amp;gt;
                &amp;lt;tr&amp;gt;
                    &amp;lt;th&amp;gt;ID&amp;lt;/th&amp;gt;
                    &amp;lt;th&amp;gt;Name&amp;lt;/th&amp;gt;
                    &amp;lt;th&amp;gt;Email&amp;lt;/th&amp;gt;
                    &amp;lt;th&amp;gt;Action&amp;lt;/th&amp;gt;
                &amp;lt;/tr&amp;gt;
            &amp;lt;/thead&amp;gt;
            &amp;lt;tbody&amp;gt;
                @foreach ($users as $user)
                &amp;lt;tr&amp;gt;
                    &amp;lt;td&amp;gt;{{ $user-&amp;gt;id }}&amp;lt;/td&amp;gt;
                    &amp;lt;td&amp;gt;{{ $user-&amp;gt;name }}&amp;lt;/td&amp;gt;
                    &amp;lt;td&amp;gt;{{ $user-&amp;gt;email }}&amp;lt;/td&amp;gt;
                    &amp;lt;td&amp;gt;
                        &amp;lt;a href="javascript:void(0)" data-url="{{ route('users.delete', $user-&amp;gt;id) }}"
                            class="btn btn-danger delete-user"&amp;gt;Delete&amp;lt;/a&amp;gt;
                    &amp;lt;/td&amp;gt;
                &amp;lt;/tr&amp;gt;
                @endforeach
            &amp;lt;/tbody&amp;gt;
        &amp;lt;/table&amp;gt;
        {!! $users-&amp;gt;withQueryString()-&amp;gt;links('pagination::bootstrap-5') !!}

    &amp;lt;/div&amp;gt;

    &amp;lt;script type="text/javascript"&amp;gt;
    $(document).ready(function() {

        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });

        /*------------------------------------------
        --------------------------------------------
        When click user on Delete Button
        --------------------------------------------
        --------------------------------------------*/
        $(document).on('click', '.delete-user', function() {

            var userURL = $(this).data('url');
            var trObj = $(this);

            if (confirm("Are you sure you want to delete this user?") == true) {
                $.ajax({
                    url: userURL,
                    type: 'DELETE',
                    dataType: 'json',
                    success: function(data) {
                        //alert(data.success);
                        trObj.parents("tr").remove();
                    }
                });
            }

        });

    });
    &amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Add Route
&lt;/h2&gt;

&lt;p&gt;Open &lt;strong&gt;web.php&lt;/strong&gt; from &lt;strong&gt;/routes&lt;/strong&gt; folder and add these route into it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//...
use App\Http\Controllers\UserController;

//...

Route::get('users', [UserController::class, 'index']);
Route::delete('users/{id}', [UserController::class, 'delete'])-&amp;gt;name('users.delete');

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Application Testing
&lt;/h2&gt;

&lt;p&gt;Run this command into project terminal to start development server,&lt;/p&gt;

&lt;p&gt;&lt;code&gt;php artisan serve&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;URL: &lt;a href="http://127.0.0.1:8000/users"&gt;http://127.0.0.1:8000/users&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It will open List of all users.&lt;/p&gt;

&lt;p&gt;Delete single user row, click on Delete button and OK.&lt;/p&gt;

&lt;p&gt;That’s it.&lt;/p&gt;

&lt;p&gt;We hope this article helped you to &lt;strong&gt;Laravel 10 How To Delete Data by Ajax Request Tutorial&lt;/strong&gt; in a very detailed way.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>php</category>
      <category>laravel</category>
    </item>
    <item>
      <title>How To Get Set Delete Cookie in laravel 10 Tutorial</title>
      <dc:creator>Sanjay Kumar</dc:creator>
      <pubDate>Thu, 14 Sep 2023 03:58:38 +0000</pubDate>
      <link>https://forem.com/webtutor/how-to-get-set-delete-cookie-in-laravel-10-tutorial-55fp</link>
      <guid>https://forem.com/webtutor/how-to-get-set-delete-cookie-in-laravel-10-tutorial-55fp</guid>
      <description>&lt;p&gt;Cookies are important in web development because they allow you to save and retrieve data from the client's browser. Cookie management in Laravel 10 is straightforward and provides a wide range of features. In this tutorial, we will walk you through the steps of getting, setting, and deleting cookies in Laravel 10.&lt;/p&gt;

&lt;p&gt;Laravel have several features which is really awesome to manage things like cookie, session, &lt;a href="https://onlinewebtutorblog.com/laravel-10-livewire-datatable-pagination/"&gt;livewire datatable&lt;/a&gt;, livewire pagination, etc. Cookie management is one of it.&lt;/p&gt;

&lt;p&gt;Laravel 10 streamlines cookie handling by providing a simple and safe mechanism for working with cookies. Cookies can be used for a variety of purposes, such as collecting user preferences, retaining session data, and even tracking user behaviour.&lt;/p&gt;

&lt;p&gt;Let's get started.&lt;/p&gt;

&lt;h2&gt;
  
  
  Laravel Installation
&lt;/h2&gt;

&lt;p&gt;Open terminal and run this command to create a laravel project.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ composer create-project laravel/laravel myblog&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It will create a project folder with name myblog inside your local system.&lt;/p&gt;

&lt;p&gt;To start the development server of laravel –&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ php artisan serve&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;URL: &lt;a href="http://127.0.0.1:8000"&gt;http://127.0.0.1:8000&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Assuming laravel already installed inside your system.&lt;/p&gt;

&lt;p&gt;What is Cookie?&lt;/p&gt;

&lt;p&gt;A cookie is a little piece of data that the server sends to the user's web browser and stores locally. Between HTTP requests and responses, cookies are often used to store user-specific data. In web development, they are essential to keep session state and user preferences.&lt;/p&gt;

&lt;h2&gt;
  
  
  How To Store Data in Laravel Cookies?
&lt;/h2&gt;

&lt;p&gt;Here, you will see two ways to store data in cookie.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using Cookie Facade&lt;/li&gt;
&lt;li&gt;Using Cookie Helper Function&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Set Cookie Data Using Cookie Facade&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We will use the concept of Cookie facade.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Cookie::queue('name', 'value', $minutes);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cookie;

class CookieController extends Controller
{

    /**
     * Write code on Method
     *
     * @return response()
     */
    public function setCookie()
    {
        Cookie::queue('owt-cookie', 'Setting Cookie from Online Web Tutor', 120);

        return response()-&amp;gt;json(['Cookie set successfully.']);
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Set Cookie Data Using Cookie Helper Function&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We will use the concept of Cookie Helper Function,&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;cookie('name', 'value', $minutes);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class CookieController extends Controller
{

    /**
     * Write code on Method
     *
     * @return response()
     */
    public function setCookie()
    {
        return response()-&amp;gt;json(['Cookie set successfully.'])-&amp;gt;cookie(

            'owt-cookie-2', 'This is a sample text inside cookie', 120
        );
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How To Get Data From Cookie in Laravel?
&lt;/h2&gt;

&lt;p&gt;Here, you will see two ways to get data from cookie.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using Cookie Facade&lt;/li&gt;
&lt;li&gt;Using Request Object&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Get Cookie Data Using Cookie Facade&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We will use the concept of Cookie facade.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Cookie::get('name')&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cookie;

class CookieController extends Controller
{

    /**
     * Write code on Method
     *
     * @return response()
     */
    public function getCookie()
    {
        $value = Cookie::get('owt-cookie');

        dd($value);
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Get Cookie Data Using Request Object&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We will use the concept of Request Object.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$request-&amp;gt;cookie('name')&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class CookieController extends Controller
{

    /**
     * Write code on Method
     *
     * @return response()
     */
    public function getCookie(Request $request)
    {
        $value2 = $request-&amp;gt;cookie('owt-cookie-2');

        dd($value2);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How To Remove Cookie Data in Laravel?
&lt;/h2&gt;

&lt;p&gt;To delete a cookie from laravel, It has a very simple method of Cookie Facade.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Cookie::forget('name')&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We hope this article helped you to learn about How To Get Set Delete Cookie in laravel 10 Tutorial in a very detailed way.&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>webdev</category>
      <category>php</category>
      <category>programming</category>
    </item>
    <item>
      <title>Laravel 10 Get Current Location Details by IP Tutorial</title>
      <dc:creator>Sanjay Kumar</dc:creator>
      <pubDate>Mon, 04 Sep 2023 03:46:40 +0000</pubDate>
      <link>https://forem.com/webtutor/laravel-10-get-current-location-details-by-ip-tutorial-4dm3</link>
      <guid>https://forem.com/webtutor/laravel-10-get-current-location-details-by-ip-tutorial-4dm3</guid>
      <description>&lt;p&gt;Using a user's IP address to obtain location information can provide useful context for your online services. Laravel 10 makes it simple to retrieve such data and enhance user experiences. This tutorial will lead you through the steps of collecting current location information using Laravel 10.&lt;/p&gt;

&lt;p&gt;An IP address is a one-of-a-kind identifier for a device on the internet or a local network. IP is an abbreviation for "Internet Protocol," which is a collection of rules that governs the format of data transferred over the internet or a local network.&lt;/p&gt;

&lt;p&gt;Laravel's integration of location services enables you to easily obtain a user's approximate geolocation information without requiring complicated preparations. In this post, we'll look at the methods provided by Laravel 10 for collecting location data, discuss the underlying physics, and demonstrate how to use them.&lt;/p&gt;

&lt;p&gt;You can also create &lt;a href="https://onlinewebtutorblog.com/laravel-10-submit-livewire-form-data/"&gt;livewire form components&lt;/a&gt; and provide user IP details but here we will only the information.&lt;/p&gt;

&lt;p&gt;Let's get this started.&lt;/p&gt;

&lt;h2&gt;
  
  
  Laravel Installation
&lt;/h2&gt;

&lt;p&gt;Open terminal and run this command to create a laravel project.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ composer create-project laravel/laravel myblog&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It will create a project folder with name myblog inside your local system.&lt;/p&gt;

&lt;p&gt;To start the development server of laravel –&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ php artisan serve&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;URL&lt;/strong&gt;: &lt;a href="http://127.0.0.1:8000"&gt;http://127.0.0.1:8000&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Assuming laravel already installed inside your system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Location Composer Package Installation
&lt;/h2&gt;

&lt;p&gt;Open project into terminal and run this composer command,&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ composer require stevebauman/Location&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It will install all needed package files into &lt;strong&gt;/vendor&lt;/strong&gt; folder.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create Location Controller
&lt;/h2&gt;

&lt;p&gt;Go to terminal and run this artisan command to create controller file.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ php artisan make:controller LocationController&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It will create &lt;strong&gt;LocationController.php&lt;/strong&gt; inside &lt;strong&gt;/app/Http/Controllers&lt;/strong&gt; folder.&lt;/p&gt;

&lt;p&gt;Open file LocationController.php and write this complete code into it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Stevebauman\Location\Facades\Location;

class LocationController extends Controller
{
    public function ip_details()
    {
        // Put your IP address
        $ip = '223.178.210.170'; 

        $data = Location::get($ip);

        return view('userinfo', compact('data'));
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Create Blade Template File
&lt;/h2&gt;

&lt;p&gt;Go to &lt;strong&gt;/resources/views&lt;/strong&gt; folder and create a file &lt;strong&gt;userinfo.blade.php&lt;/strong&gt; inside it.&lt;/p&gt;

&lt;p&gt;Open userinfo.blade.php and write this complete into it,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8"&amp;gt;
    &amp;lt;title&amp;gt;Laravel 10 Get Current Location Details Tutorial&amp;lt;/title&amp;gt;
    &amp;lt;link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;

&amp;lt;div class="container" style="margin-top: 20px;"&amp;gt;
    &amp;lt;h3&amp;gt;Laravel 10 Get Current Location Details Tutorial&amp;lt;/h3&amp;gt;
    &amp;lt;div class="card"&amp;gt;
        &amp;lt;div class="card-body"&amp;gt;
            @if($data)
                &amp;lt;h4&amp;gt;IP: {{ $data-&amp;gt;ip }}&amp;lt;/h4&amp;gt;
                &amp;lt;h4&amp;gt;Country Name: {{ $data-&amp;gt;countryName }}&amp;lt;/h4&amp;gt;
                &amp;lt;h4&amp;gt;Country Code: {{ $data-&amp;gt;countryCode }}&amp;lt;/h4&amp;gt;
                &amp;lt;h4&amp;gt;Region Code: {{ $data-&amp;gt;regionCode }}&amp;lt;/h4&amp;gt;
                &amp;lt;h4&amp;gt;Region Name: {{ $data-&amp;gt;regionName }}&amp;lt;/h4&amp;gt;
                &amp;lt;h4&amp;gt;City Name: {{ $data-&amp;gt;cityName }}&amp;lt;/h4&amp;gt;
                &amp;lt;h4&amp;gt;Zip Code: {{ $data-&amp;gt;zipCode }}&amp;lt;/h4&amp;gt;
                &amp;lt;h4&amp;gt;Latitude: {{ $data-&amp;gt;latitude }}&amp;lt;/h4&amp;gt;
                &amp;lt;h4&amp;gt;Longitude: {{ $data-&amp;gt;longitude }}&amp;lt;/h4&amp;gt;
            @endif
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;

&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Add Route
&lt;/h2&gt;

&lt;p&gt;Open &lt;strong&gt;web.php&lt;/strong&gt; file from &lt;strong&gt;/routes&lt;/strong&gt; folder. You need to add a route into it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//...

use App\Http\Controllers\LocationController;

Route::get('ip-details', [LocationController::class, 'ip_details'])-&amp;gt;name('ip_details');

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Application Testing
&lt;/h2&gt;

&lt;p&gt;Open project to terminal and type the command to start development server&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ php artisan serve&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;URL&lt;/strong&gt;: &lt;a href="http://127.0.0.1:8000/ip-details"&gt;http://127.0.0.1:8000/ip-details&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We hope this article helped you to learn about Laravel 10 Get Current Location Details by IP Tutorial in a very detailed way.&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>webdev</category>
      <category>development</category>
    </item>
    <item>
      <title>CodeIgniter 4 Create Custom Validation Rule Tutorial</title>
      <dc:creator>Sanjay Kumar</dc:creator>
      <pubDate>Sun, 27 Aug 2023 10:23:43 +0000</pubDate>
      <link>https://forem.com/webtutor/codeigniter-4-create-custom-validation-rule-tutorial-2bfm</link>
      <guid>https://forem.com/webtutor/codeigniter-4-create-custom-validation-rule-tutorial-2bfm</guid>
      <description>&lt;p&gt;Creating personalised validation rules in your CodeIgniter 4 applications is critical for assuring data accuracy and user input integrity. By creating custom rules tailored to your project’s specific needs, you not only improve the precision of your validation process but also streamline the entire operation of your application.&lt;/p&gt;

&lt;p&gt;CodeIgniter also provides several pre-defined rules in application. You can learn the basic concept of &lt;a href="https://onlinewebtutorblog.com/codeigniter-4-form-validation-library/"&gt;form validation of CodeIgniter&lt;/a&gt; from here.&lt;/p&gt;

&lt;h2&gt;
  
  
  CodeIgniter 4 Installation
&lt;/h2&gt;

&lt;p&gt;To create a CodeIgniter 4 setup run this given command into your shell or terminal. Please make sure composer should be installed.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ composer create-project codeigniter4/appstarter codeigniter-4&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Assuming you have successfully installed application into your local system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Register Custom Validation Rule
&lt;/h2&gt;

&lt;p&gt;First you have to create validation file and then register.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example #1: Create Validation File (Mobile Validation)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Purpose: This validation rule basically checks the pattern of mobile number, length and then validate it.&lt;/p&gt;

&lt;p&gt;Open project terminal and run this command,&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ php spark make:validation Mobile --suffix&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It will create a file with name &lt;strong&gt;MobileValidation.php&lt;/strong&gt; inside /app/Validation folder. Validation folder was not available before running above command but when it generated validation file. It also created that folder as well.&lt;/p&gt;

&lt;p&gt;Open MobileValidation.php file and write this piece of code into it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Validation;

class MobileValidation
{
    public function checkMobile($value, string &amp;amp;$error = null): bool
    {
        /*Checking: Number must start from 5-9{Rest Numbers}*/
        if(preg_match( '/^[5-9]{1}[0-9]+/', $value)){

            /*Checking: Mobile number must be of 10 digits*/
            if(!preg_match('/^[0-9]{10}+$/', $value)){

                $error = "Mobile number is not valid";
                return false;
            }
            return true;
        }else{  
            return false;
        }
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Register Custom Validation Class
&lt;/h2&gt;

&lt;p&gt;Load custom validation to application.&lt;/p&gt;

&lt;p&gt;Open &lt;strong&gt;Validation.php&lt;/strong&gt; file from /app/Config folder. Inside this you have to register your custom validation rules.&lt;/p&gt;

&lt;p&gt;Search for &lt;strong&gt;$ruleSets&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//...

# Add at header
use \App\Validation\MobileValidation;
use \App\Validation\NameValidation;

/**
* Stores the classes that contain the
* rules that are available.
*
* @var string[]
*/
public array $ruleSets = [
    Rules::class,
    FormatRules::class,
    FileRules::class,
    CreditCardRules::class,
    MobileValidation::class, // custom rule
    NameValidation::class, // custom rule
];

//...

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Concept to Use: Custom Validation Rule
&lt;/h2&gt;

&lt;p&gt;Use Custom added validation rules.&lt;/p&gt;

&lt;p&gt;Let’s say we have a form in which we have a input field for mobile number and full name. Next, we need to add form validation rules in code where we are submitting form data.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;"mobile" =&amp;gt; "required|checkMobile"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here, as we can see we have two different rules for input type mobile.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;required&lt;/strong&gt; is the predefined validation rule in codeigniter 4&lt;br&gt;
&lt;strong&gt;checkMobile&lt;/strong&gt; is custom rule added to check a valid mobile number.&lt;/p&gt;

&lt;p&gt;We hope this article helped you to learn about CodeIgniter 4 Create Custom Validation Rule Tutorial in a very detailed way.&lt;/p&gt;

</description>
      <category>codeigniter</category>
      <category>php</category>
      <category>programmers</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Laravel 10 Telescope: Debugging and Monitoring Tool</title>
      <dc:creator>Sanjay Kumar</dc:creator>
      <pubDate>Sun, 20 Aug 2023 10:05:08 +0000</pubDate>
      <link>https://forem.com/webtutor/laravel-10-telescope-debugging-and-monitoring-tool-12ih</link>
      <guid>https://forem.com/webtutor/laravel-10-telescope-debugging-and-monitoring-tool-12ih</guid>
      <description>&lt;p&gt;Laravel 10 has a robust debugging and profiling tool called &lt;strong&gt;Telescope&lt;/strong&gt; which provides developers with unprecedented insight into the performance, queries, and other aspects of their application. Telescope allows you to delve deep into the inner workings of your Laravel application, discovering bottlenecks, tracking requests, and acquiring a thorough insight of its behaviour.&lt;/p&gt;

&lt;p&gt;This tutorial will walk you through the process of &lt;strong&gt;working with Telescope in Laravel 10&lt;/strong&gt;. We’ll lead you through installing Telescope, examining its features, and utilising its capabilities to optimise and troubleshoot your application.&lt;/p&gt;

&lt;p&gt;Additionally, you can use also &lt;a href="https://onlinewebtutorblog.com/laravel-10-logviewer/"&gt;log-viewer of laravel&lt;/a&gt; for logging all errors into an UI view for users.&lt;/p&gt;

&lt;p&gt;Let’s get started.&lt;/p&gt;

&lt;h2&gt;
  
  
  Laravel Installation
&lt;/h2&gt;

&lt;p&gt;Open terminal and run this command to create a laravel project.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ composer create-project laravel/laravel myblog&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It will create a project folder with name myblog inside your local system.&lt;/p&gt;

&lt;p&gt;To start the development server of laravel –&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ php artisan serve&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;URL: &lt;a href="http://127.0.0.1:8000"&gt;http://127.0.0.1:8000&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Assuming laravel already installed inside your system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create Database &amp;amp; Connect
&lt;/h2&gt;

&lt;p&gt;To create a database, either we can create via Manual tool of PhpMyadmin or by means of a mysql command.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;CREATE DATABASE laravel_app;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;To connect database with application, Open .env file from application root. Search for DB_ and update your details.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel_app
DB_USERNAME=root
DB_PASSWORD=root
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What is Laravel Telescope?
&lt;/h2&gt;

&lt;p&gt;Laravel Telescope is a powerful debugging and introspection tool for Laravel apps. Telescope, which was created by the Laravel community, gives developers real-time visibility into the performance, behaviour, and interactions of their applications.&lt;/p&gt;

&lt;p&gt;It has a number of features that make it easier to find and diagnose problems, optimise performance, and obtain a better understanding of how the application works.&lt;/p&gt;

&lt;p&gt;Telescope provides insight into the requests coming into your application, exceptions, log entries, database queries, queued jobs, mail, notifications, cache operations, scheduled tasks, variable dumps and more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Features of Laravel Telescope
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Real-Time Monitoring:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Telescope has a live dashboard that displays real-time information about the application’s HTTP requests, queries, jobs, events, and more. Developers may keep track of what’s going on within the programme as it happens.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Database Queries:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Telescope captures and shows all database queries that are executed, allowing developers to identify inefficient queries, analyse query performance, and optimise database interactions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HTTP Requests:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It records information about incoming HTTP requests, such as route information, request and response data, headers, and more. This is useful for troubleshooting routing and request handling issues.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scheduled Tasks and Jobs:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Telescope gives insights into scheduled tasks and background jobs, assisting developers in tracking their execution status, parameters, and runtime performance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Notification and Events:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Developers can keep track of the alerts and events that occur within the programme. Telescope displays information about events that have been dispatched, event listeners, and notification content.&lt;/p&gt;

&lt;p&gt;Read More: Laravel 10 Seed Database Using Faker Library Tutorial&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Redis Operations:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Telescope captures Redis commands and actions, making it easier to troubleshoot caching, session management, and data storage issues.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Artisan Commands:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Telescope logs information about Artisan commands that are executed within the programme, assisting developers in tracking command execution, input, output, and runtime.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User Interface:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;User design: The Telescope dashboard includes a user-friendly design that allows developers to easily move through the gathered data, allowing for more effective debugging and analysis.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Customizing and Filtering:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Developers can customise and filter what Telescope catches and displays. This is handy for focusing on specific areas of the application or disabling monitoring of sensitive data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Telescope Features List&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These are the features of Telescope which used to monitor application stats,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Requests&lt;/li&gt;
&lt;li&gt;Commands&lt;/li&gt;
&lt;li&gt;Schedule&lt;/li&gt;
&lt;li&gt;Jobs&lt;/li&gt;
&lt;li&gt;Batches&lt;/li&gt;
&lt;li&gt;Cache&lt;/li&gt;
&lt;li&gt;Dumps&lt;/li&gt;
&lt;li&gt;Events&lt;/li&gt;
&lt;li&gt;Exceptions&lt;/li&gt;
&lt;li&gt;Gates&lt;/li&gt;
&lt;li&gt;Logs&lt;/li&gt;
&lt;li&gt;Mail&lt;/li&gt;
&lt;li&gt;Models&lt;/li&gt;
&lt;li&gt;Notifications&lt;/li&gt;
&lt;li&gt;Queries&lt;/li&gt;
&lt;li&gt;Redis&lt;/li&gt;
&lt;li&gt;Views&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Laravel Telescope Installation (Package)
&lt;/h2&gt;

&lt;p&gt;Laravel telescope is a composer package which is developed to use it for laravel applications. It is used to keep track of laravel requests, commands, exceptions, gates, etc.&lt;/p&gt;

&lt;p&gt;Open project into terminal and run this command.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ composer require laravel/telescope&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can also install for local environment:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ composer require laravel/telescope --dev&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Once it will be installed, you can see &lt;strong&gt;“commands of Telescope”&lt;/strong&gt; into artisan command list.&lt;/p&gt;

&lt;h2&gt;
  
  
  Publish Telescope: Generate Scaffolding Files
&lt;/h2&gt;

&lt;p&gt;It will generate Telescope associated service provider, assets, configuration etc.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ php artisan telescope:install&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Read More: Laravel 10 How To Setup Ajax Request Tutorial&lt;/p&gt;

&lt;p&gt;It generates all needed files.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Publishing Telescope Service Provider...
Publishing Telescope Assets...
Publishing Telescope Configuration...
Telescope scaffolding installed successfully.
Migrate Telescope Migration
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;$ php artisan migrate&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;All we done! No more settings required.&lt;/p&gt;

&lt;h2&gt;
  
  
  Application Testing
&lt;/h2&gt;

&lt;p&gt;Open project to terminal and type the command to start development server&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ php artisan serve&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;URL: &lt;a href="http://localhost:8000/telescope/requests"&gt;http://localhost:8000/telescope/requests&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Telescope Package Files
&lt;/h2&gt;

&lt;p&gt;You can find the installed package files into this location&lt;/p&gt;

&lt;p&gt;&lt;code&gt;vendor/laravel/telescope&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We hope this article helped you to learn about &lt;strong&gt;Laravel 10 Telescope: Debugging and Monitoring Tool&lt;/strong&gt; in a very detailed way.&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Laravel 10 How To Setup Ajax Request Tutorial</title>
      <dc:creator>Sanjay Kumar</dc:creator>
      <pubDate>Mon, 14 Aug 2023 06:57:30 +0000</pubDate>
      <link>https://forem.com/webtutor/laravel-10-how-to-setup-ajax-request-tutorial-2a58</link>
      <guid>https://forem.com/webtutor/laravel-10-how-to-setup-ajax-request-tutorial-2a58</guid>
      <description>&lt;p&gt;In the ever-changing web development ecosystem, Ajax (Asynchronous JavaScript and XML) has emerged as a vital technology for constructing interactive and responsive web applications.&lt;/p&gt;

&lt;p&gt;Setting up Ajax requests in Laravel 10 facilitates communication between your frontend and backend, allowing for real-time updates and improved user experiences without the need for full page reloads.&lt;/p&gt;

&lt;p&gt;We will walk you through the process of configuring Ajax requests in &lt;a href="https://onlinewebtutorblog.com/category/laravel-10/" rel="noopener noreferrer"&gt;Laravel 10&lt;/a&gt; in this tutorial. We'll look at how to utilise JavaScript and jQuery to send asynchronous queries to your backend, provide data, and handle real-time responses.&lt;/p&gt;

&lt;p&gt;Let's get started.&lt;/p&gt;

&lt;h2&gt;
  
  
  Laravel Installation
&lt;/h2&gt;

&lt;p&gt;Open terminal and run this command to create a laravel project.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ composer create-project laravel/laravel myblog&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It will create a project folder with name myblog inside your local system.&lt;/p&gt;

&lt;p&gt;To start the development server of laravel –&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ php artisan serve&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;URL: &lt;a href="http://127.0.0.1:8000" rel="noopener noreferrer"&gt;http://127.0.0.1:8000&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Assuming laravel already installed inside your system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Settings Up Controller
&lt;/h2&gt;

&lt;p&gt;Open project into terminal and type this command to create controller file.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ php artisan make:controller AjaxController&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This command will create a file i.e &lt;strong&gt;AjaxController.php&lt;/strong&gt; inside &lt;strong&gt;/app/Http/Controllers&lt;/strong&gt; folder.&lt;/p&gt;

&lt;p&gt;Open this file and write this complete code into it.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&amp;lt;?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class AjaxController extends Controller
{
    public function myPost()
    {
        return view('my-post');
    }

    public function submitPost(Request $request)
    {
        // We are collecting all data submitting via Ajax
        $input = $request-&amp;gt;all();

        // Sending json response to client
        return response()-&amp;gt;json([
            "status" =&amp;gt; true,
            "data" =&amp;gt; $input
        ]);
    }
}



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Inside this above code, you have added a method which is processing ajax data. You can even use this data to insert into database table.&lt;/p&gt;

&lt;p&gt;Next,&lt;/p&gt;

&lt;h2&gt;
  
  
  Create Blade Template
&lt;/h2&gt;

&lt;p&gt;Go inside &lt;strong&gt;/resources/views&lt;/strong&gt; folder. Create a file called &lt;strong&gt;my-post.blade.php&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Open up the file and write this complete code into it.&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&lt;p&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;br&gt;
&amp;lt;html lang="en"&amp;gt;&lt;/p&gt;

&lt;p&gt;&amp;lt;head&amp;gt;&lt;br&gt;
    &amp;lt;title&amp;gt;Laravel 10 How To Setup Ajax Request Tutorial - Online Web Tutor&amp;lt;/title&amp;gt;&lt;br&gt;
    &amp;lt;meta charset="utf-8"&amp;gt;&lt;br&gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1"&amp;gt;&lt;br&gt;
    &amp;lt;link rel="stylesheet" href="&lt;a href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="noopener noreferrer"&gt;https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css&lt;/a&gt;"&amp;gt;&lt;br&gt;
    &amp;lt;script src="&lt;a href="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js%22&amp;gt;&amp;lt;/script" rel="noopener noreferrer"&gt;https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"&amp;amp;gt;&amp;amp;lt;/script&lt;/a&gt;&amp;gt;&lt;br&gt;
    &amp;lt;script src="&lt;a href="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js%22&amp;gt;&amp;lt;/script" rel="noopener noreferrer"&gt;https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"&amp;amp;gt;&amp;amp;lt;/script&lt;/a&gt;&amp;gt;&lt;br&gt;
    &amp;lt;script src="&lt;a href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js%22&amp;gt;&amp;lt;/script" rel="noopener noreferrer"&gt;https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"&amp;amp;gt;&amp;amp;lt;/script&lt;/a&gt;&amp;gt;&lt;br&gt;
    &amp;lt;meta name="csrf-token" content="{{ csrf_token() }}" /&amp;gt;&lt;br&gt;
    &amp;lt;style&amp;gt;&lt;br&gt;
    #frm-create-post label.error {&lt;br&gt;
        color: red;&lt;br&gt;
    }&lt;br&gt;
    &amp;lt;/style&amp;gt;&lt;br&gt;
&amp;lt;/head&amp;gt;&lt;/p&gt;

&lt;p&gt;&amp;lt;body&amp;gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;amp;lt;div class="container" style="margin-top: 50px;"&amp;amp;gt;
    &amp;amp;lt;h4 style="text-align: center;"&amp;amp;gt;Laravel 10 How To Setup Ajax Request Tutorial - Online Web Tutor&amp;amp;lt;/h4&amp;amp;gt;
    &amp;amp;lt;form action="javascript:void(0)" id="frm-create-post" method="post"&amp;amp;gt;
        &amp;amp;lt;div class="form-group"&amp;amp;gt;
            &amp;amp;lt;label for="name"&amp;amp;gt;Name:&amp;amp;lt;/label&amp;amp;gt;
            &amp;amp;lt;input type="text" class="form-control" required id="name" name="name" placeholder="Enter name"&amp;amp;gt;
        &amp;amp;lt;/div&amp;amp;gt;
        &amp;amp;lt;div class="form-group"&amp;amp;gt;
            &amp;amp;lt;label for="description"&amp;amp;gt;Description:&amp;amp;lt;/label&amp;amp;gt;
            &amp;amp;lt;textarea class="form-control" id="description" required name="description"
                placeholder="Enter description"&amp;amp;gt;&amp;amp;lt;/textarea&amp;amp;gt;
        &amp;amp;lt;/div&amp;amp;gt;
        &amp;amp;lt;div class="form-group"&amp;amp;gt;
            &amp;amp;lt;label for="status"&amp;amp;gt;Status:&amp;amp;lt;/label&amp;amp;gt;
            &amp;amp;lt;select class="form-control" id="status" name="status"&amp;amp;gt;
                &amp;amp;lt;option value="1"&amp;amp;gt;Active&amp;amp;lt;/option&amp;amp;gt;
                &amp;amp;lt;option value="0"&amp;amp;gt;Inactive&amp;amp;lt;/option&amp;amp;gt;
            &amp;amp;lt;/select&amp;amp;gt;
        &amp;amp;lt;/div&amp;amp;gt;

        &amp;amp;lt;button type="submit" class="btn btn-primary" id="submit-post"&amp;amp;gt;Submit&amp;amp;lt;/button&amp;amp;gt;
    &amp;amp;lt;/form&amp;amp;gt;
&amp;amp;lt;/div&amp;amp;gt;

&amp;amp;lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.2/jquery.validate.min.js"&amp;amp;gt;&amp;amp;lt;/script&amp;amp;gt;

&amp;amp;lt;script type="text/javascript"&amp;amp;gt;
    $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });

    $("#frm-create-post").validate({

        submitHandler: function() {

            var name = $("#name").val();
            var description = $("#description").val();
            var status = $("#status").val();

            // processing ajax request    
            $.ajax({
                url: "{{ route('postSubmit') }}",
                type: 'POST',
                dataType: "json",
                data: {
                    name: name,
                    description: description,
                    status: status
                },
                success: function(data) {
                    // log response into console
                    console.log(data);
                }
            });
        }
    });
&amp;amp;lt;/script&amp;amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;&amp;lt;/body&amp;gt;&lt;/p&gt;

&lt;p&gt;&amp;lt;/html&amp;gt;&lt;/p&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Add Route&lt;br&gt;
&lt;/h2&gt;

&lt;p&gt;Open &lt;strong&gt;web.php&lt;/strong&gt; file from &lt;strong&gt;/routes&lt;/strong&gt; folder. Add these routes into it.&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&lt;p&gt;//...&lt;br&gt;
use App\Http\Controllers\AjaxController;&lt;/p&gt;

&lt;p&gt;Route::get('add-post', [AjaxController::class, 'myPost']);&lt;br&gt;
Route::post('submit-post', [AjaxController::class, 'submitPost'])-&amp;gt;name('postSubmit');&lt;/p&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Application Testing&lt;br&gt;
&lt;/h2&gt;

&lt;p&gt;Open project to terminal and type the command to start development server&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ php artisan serve&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;URL:&lt;/strong&gt; &lt;a href="http://localhost:8000/add-post" rel="noopener noreferrer"&gt;http://localhost:8000/add-post&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Submitting Data and getting response to Console&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxnnb5sp0ub9pnrip0gq6.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxnnb5sp0ub9pnrip0gq6.jpg" alt="Ajax request setup in Laravel 10"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We hope this article helped you to learn about &lt;strong&gt;Laravel 10 How To Setup Ajax Request Tutorial&lt;/strong&gt; in a very detailed way.&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
