  {"id":337,"date":"2022-09-24T16:03:06","date_gmt":"2022-09-24T16:03:06","guid":{"rendered":"https:\/\/247blogs.com\/wp\/2022\/09\/24\/laravel-9-tutorial-laravel-9-validate-internet-protocol-ipv6-tutorial\/"},"modified":"2022-09-24T17:41:04","modified_gmt":"2022-09-24T17:41:04","slug":"laravel-9-tutorial-laravel-9-validate-internet-protocol-ipv6-tutorial","status":"publish","type":"post","link":"https:\/\/247blogs.com\/wp\/laravel-9-tutorial-laravel-9-validate-internet-protocol-ipv6-tutorial\/","title":{"rendered":"Laravel-9 Tutorial &#8211; Laravel 9 Validate Internet Protocol (IPv6) Tutorial"},"content":{"rendered":"<div id=\"\">\n<p>Laravel 9 IPv6 validation example; Since IPv6 (Internet Protocol version 6) is the newest addition to Internet Protocol, It is way better than IPv4. It offers distinctive IP addresses essential for Internet-enabled devices to communicate.<\/p>\n<p>In this tutorial, you will find out how to add validation for the IPv6 input field in the Laravel 9 simple app. To integrate the validation for IPv6, we will be using Laravel\u2019s default request method along with Bootstrap 5.<\/p>\n<p>To incorporate the validation in IPv6, we will begin with a basic Laravel app installation, generate and set up a laravel controller particularly for IPv6 validation.<\/p>\n<p>Then move on to create routes for handling the request, and build the form using Bootstrap and test the laravel IPv6 server-side validation.<\/p>\n<h2>How to Validate IPv6 (Internet Protocol Version 6) in Laravel 9<\/h2>\n<ul>\n<li><strong>Step 1:<\/strong> Install Laravel App<\/li>\n<li><strong>Step 2:<\/strong> Generate Controller<\/li>\n<li><strong>Step 3:<\/strong> Set Up Controller<\/li>\n<li><strong>Step 4:<\/strong> Define Routes<\/li>\n<li><strong>Step 5:<\/strong> Build Form with Bootstrap<\/li>\n<li><strong>Step 6:<\/strong> Test IPv6 Validation<\/li>\n<\/ul>\n<h2>Install Laravel App<\/h2>\n<p>In order to install the fresh Laravel application, make sure to configure Composer tool on your development machine.<\/p>\n<p>Open the terminal, on the command-prompt hit the given command and execute the command to download the app.<\/p>\n<pre class=\" language-markup\" tabindex=\"0\"><code class=\"  language-bash\"><span class=\"token function\">composer<\/span> create-project --prefer-dist laravel\/laravel laravel-boom<\/code><\/pre>\n<p>Once the app is generated, move inside the app directory.<\/p>\n<pre class=\" language-markup\" tabindex=\"0\"><code class=\"  language-bash\"><span class=\"token builtin class-name\">cd<\/span> laravel-boom<\/code><\/pre>\n<h2>Generate Controller<\/h2>\n<p>A controller handles the core logic of Laravel apps, and it\u2019s just a simple file where all the feature-related code resides.<\/p>\n<p>You may create it manually or simply invoke the suggested below command from the command prompt.<\/p>\n<pre class=\" language-markup\" tabindex=\"0\"><code class=\" language-bash\">php artisan make:controller ProductController<\/code><\/pre>\n<p>Now the ProductController file has been created, you now have to follow the subsequent step.<\/p>\n<h2>Set Up Controller<\/h2>\n<p>Get into the <strong>appHttpControllers<\/strong> directory and look for <strong>ProductController.php<\/strong> file. In this file you have to place the suggested code.<\/p>\n<pre class=\"language-php\" tabindex=\"0\"><code class=\"language-php\"><span class=\"token php language-php\"><span class=\"token delimiter important\"><?php<\/span>\n<span class=\"token keyword\">namespace<\/span> <span class=\"token package\">App<span class=\"token punctuation\"><\/span>Http<span class=\"token punctuation\"><\/span>Controllers<\/span><span class=\"token punctuation\">;<\/span>\n<span class=\"token keyword\">use<\/span> <span class=\"token package\">Illuminate<span class=\"token punctuation\"><\/span>Http<span class=\"token punctuation\"><\/span>Request<\/span><span class=\"token punctuation\">;<\/span>\n<span class=\"token keyword\">use<\/span> <span class=\"token package\">Illuminate<span class=\"token punctuation\"><\/span>Support<span class=\"token punctuation\"><\/span>Facades<span class=\"token punctuation\"><\/span>Blade<\/span><span class=\"token punctuation\">;<\/span>\n<span class=\"token keyword\">class<\/span> <span class=\"token class-name-definition class-name\">ProductController<\/span> <span class=\"token keyword\">extends<\/span> <span class=\"token class-name\">Controller<\/span>\n<span class=\"token punctuation\">{<\/span>\n    <span class=\"token keyword\">public<\/span> <span class=\"token keyword\">function<\/span> <span class=\"token function-definition function\">ipv6form<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span>\n    <span class=\"token punctuation\">{<\/span>\n        <span class=\"token keyword\">return<\/span> <span class=\"token function\">view<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string single-quoted-string\">'index'<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\n    <span class=\"token punctuation\">}<\/span>\n    <span class=\"token keyword\">public<\/span> <span class=\"token keyword\">function<\/span> <span class=\"token function-definition function\">validateForm<\/span><span class=\"token punctuation\">(<\/span><span class=\"token class-name type-declaration\">Request<\/span> <span class=\"token variable\">$request<\/span><span class=\"token punctuation\">)<\/span>\n    <span class=\"token punctuation\">{<\/span>\n        <span class=\"token variable\">$request<\/span><span class=\"token operator\">-><\/span><span class=\"token function\">validate<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">[<\/span>\n            <span class=\"token string single-quoted-string\">'ip_address'<\/span> <span class=\"token operator\">=><\/span> <span class=\"token string single-quoted-string\">'required|ipv6'<\/span><span class=\"token punctuation\">,<\/span>\n        <span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\n        <span class=\"token function\">dd<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string single-quoted-string\">'Form submitted successfully!'<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\n    <span class=\"token punctuation\">}<\/span>\n<span class=\"token punctuation\">}<\/span><\/span><\/code><\/pre>\n<p>The ProductController class, will have the two functions and handle the view for the form and required validation for the IPv6 input field.<\/p>\n<h2>Define Routes<\/h2>\n<p>To build the routes for handling the form and validation, get inside the <strong>routes\/<\/strong> folder and add the given code into the <strong>web.php<\/strong> file.<\/p>\n<pre class=\"language-php\" tabindex=\"0\"><code class=\"language-php\"><span class=\"token php language-php\"><span class=\"token delimiter important\"><?php<\/span>\n<span class=\"token keyword\">use<\/span> <span class=\"token package\">Illuminate<span class=\"token punctuation\"><\/span>Support<span class=\"token punctuation\"><\/span>Facades<span class=\"token punctuation\"><\/span>Route<\/span><span class=\"token punctuation\">;<\/span>\n<span class=\"token keyword\">use<\/span> <span class=\"token package\">App<span class=\"token punctuation\"><\/span>Http<span class=\"token punctuation\"><\/span>Controllers<span class=\"token punctuation\"><\/span>ProductController<\/span><span class=\"token punctuation\">;<\/span>\n\n<span class=\"token class-name static-context\">Route<\/span><span class=\"token operator\">::<\/span><span class=\"token function\">get<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string single-quoted-string\">'\/my-form'<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token class-name static-context\">ProductController<\/span><span class=\"token operator\">::<\/span><span class=\"token keyword\">class<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string single-quoted-string\">'ipv6form'<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\n<span class=\"token class-name static-context\">Route<\/span><span class=\"token operator\">::<\/span><span class=\"token function\">post<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string single-quoted-string\">'\/submit-form'<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token class-name static-context\">ProductController<\/span><span class=\"token operator\">::<\/span><span class=\"token keyword\">class<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string single-quoted-string\">'validateForm'<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><span class=\"token operator\">-><\/span><span class=\"token function\">name<\/span><span class=\"token punctuation\">(<\/span>\n    <span class=\"token string single-quoted-string\">'validate.ip'<\/span>\n<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/span><\/code><\/pre>\n<h2>Build Form with Bootstrap<\/h2>\n<p>Now, you need to go to <strong>resources\/views\/<\/strong> folder, inside this folder you have create <strong>index.blade.php<\/strong> file and insert the suggested code into the view file.<\/p>\n<pre class=\"language-php\" tabindex=\"0\"><code class=\"language-php\"><span class=\"token operator\"><<\/span><span class=\"token operator\">!<\/span><span class=\"token constant\">DOCTYPE<\/span> html<span class=\"token operator\">><\/span>\n<span class=\"token operator\"><<\/span>html<span class=\"token operator\">><\/span>\n<span class=\"token operator\"><<\/span>head<span class=\"token operator\">><\/span>\n    <span class=\"token operator\"><<\/span>title<span class=\"token operator\">><\/span>Laravel IPv6 Validation<span class=\"token operator\"><<\/span><span class=\"token operator\">\/<\/span>title<span class=\"token operator\">><\/span>\n    <span class=\"token operator\"><<\/span>link href<span class=\"token operator\">=<\/span><span class=\"token string double-quoted-string\">\"https:\/\/cdn.jsdelivr.net\/npm\/bootstrap@5.1.3\/dist\/css\/bootstrap.min.css\"<\/span> rel<span class=\"token operator\">=<\/span><span class=\"token string double-quoted-string\">\"stylesheet\"<\/span><span class=\"token operator\">><\/span>\n<span class=\"token operator\"><<\/span><span class=\"token operator\">\/<\/span>head<span class=\"token operator\">><\/span>\n<span class=\"token operator\"><<\/span>body<span class=\"token operator\">><\/span>\n    <span class=\"token operator\"><<\/span>div <span class=\"token keyword\">class<\/span><span class=\"token operator\">=<\/span><span class=\"token string double-quoted-string\">\"container mt-5\"<\/span><span class=\"token operator\">><\/span>\n        @<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token function\">count<\/span><span class=\"token punctuation\">(<\/span><span class=\"token variable\">$errors<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">><\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span>\n            <span class=\"token operator\"><<\/span>div <span class=\"token keyword\">class<\/span><span class=\"token operator\">=<\/span><span class=\"token string double-quoted-string\">\"alert alert-danger\"<\/span><span class=\"token operator\">><\/span>\n                @<span class=\"token keyword\">foreach<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token variable\">$errors<\/span><span class=\"token operator\">-><\/span><span class=\"token function\">all<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">as<\/span> <span class=\"token variable\">$error<\/span><span class=\"token punctuation\">)<\/span>\n                    <span class=\"token punctuation\">{<\/span><span class=\"token punctuation\">{<\/span> <span class=\"token variable\">$error<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">}<\/span> <span class=\"token operator\"><<\/span>br<span class=\"token operator\">><\/span>\n                @<span class=\"token keyword\">endforeach<\/span>\n            <span class=\"token operator\"><<\/span><span class=\"token operator\">\/<\/span>div<span class=\"token operator\">><\/span>\n        @<span class=\"token keyword\">endif<\/span>\n        <span class=\"token operator\"><<\/span>form action<span class=\"token operator\">=<\/span><span class=\"token string double-quoted-string\">\"{{ route('validate.ip') }}\"<\/span> method<span class=\"token operator\">=<\/span><span class=\"token string double-quoted-string\">\"post\"<\/span><span class=\"token operator\">><\/span>\n            @csrf\n            <span class=\"token operator\"><<\/span>div <span class=\"token keyword\">class<\/span><span class=\"token operator\">=<\/span><span class=\"token string double-quoted-string\">\"mb-3\"<\/span><span class=\"token operator\">><\/span>\n                <span class=\"token operator\"><<\/span>label<span class=\"token operator\">><\/span><span class=\"token constant\">IP<\/span> Address<span class=\"token operator\"><<\/span><span class=\"token operator\">\/<\/span>label<span class=\"token operator\">><\/span>\n                <span class=\"token operator\"><<\/span>input type<span class=\"token operator\">=<\/span><span class=\"token string double-quoted-string\">\"text\"<\/span> <span class=\"token keyword\">class<\/span><span class=\"token operator\">=<\/span><span class=\"token string double-quoted-string\">\"form-control\"<\/span> name<span class=\"token operator\">=<\/span><span class=\"token string double-quoted-string\">\"ip_address\"<\/span><span class=\"token operator\">><\/span>\n            <span class=\"token operator\"><<\/span><span class=\"token operator\">\/<\/span>div<span class=\"token operator\">><\/span>\n            <span class=\"token operator\"><<\/span>div<span class=\"token operator\">><\/span>\n                <span class=\"token operator\"><<\/span>button <span class=\"token keyword\">class<\/span><span class=\"token operator\">=<\/span><span class=\"token string double-quoted-string\">\"btn btn-danger\"<\/span><span class=\"token operator\">><\/span>Send<span class=\"token operator\"><<\/span><span class=\"token operator\">\/<\/span>button<span class=\"token operator\">><\/span>\n            <span class=\"token operator\"><<\/span><span class=\"token operator\">\/<\/span>div<span class=\"token operator\">><\/span>\n        <span class=\"token operator\"><<\/span><span class=\"token operator\">\/<\/span>form<span class=\"token operator\">><\/span>\n    <span class=\"token operator\"><<\/span><span class=\"token operator\">\/<\/span>div<span class=\"token operator\">><\/span>\n<span class=\"token operator\"><<\/span><span class=\"token operator\">\/<\/span>body<span class=\"token operator\">><\/span>\n<span class=\"token operator\"><<\/span><span class=\"token operator\">\/<\/span>html<span class=\"token operator\">><\/span><\/code><\/pre>\n<p>Add the bootstrap CSS link within the head section to allow building the form using bootstrap form UI component.<\/p>\n<p>Define the form tag, pass the route that makes the post request and evoke the server side validation for IPv6 form field.<\/p>\n<h2>Test IPv6 Validation<\/h2>\n<p>In this segment, we have to just run the laravel development server. Hence, execute the given command to run the app.<\/p>\n<pre class=\"  language-bash\"><code class=\"  language-bash\">php artisan serve<\/code><\/pre>\n<p>You can test or view the app through given url:<\/p>\n<pre class=\" language-markup\" tabindex=\"0\"><code class=\" language-bash\">http:\/\/127.0.0.1:8000\/my-form<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.positronx.io\/wp-content\/uploads\/2022\/05\/15872-01.jpg\" alt=\"Laravel 9 Validate Internet Protocol (IPv6) Tutorial\" width=\"1000\" height=\"478\" class=\"alignnone size-full wp-image-18466\" srcset=\"https:\/\/www.positronx.io\/wp-content\/uploads\/2022\/05\/15872-01.jpg 1000w, https:\/\/www.positronx.io\/wp-content\/uploads\/2022\/05\/15872-01-768x367.jpg 768w, https:\/\/www.positronx.io\/wp-content\/uploads\/2022\/05\/15872-01-302x144.jpg 302w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\"><\/p>\n<h2>Conclusion<\/h2>\n<p>If you\u2019ve never implemented IPv6 validation in Laravel before, you may have discovered how to include the required validation for IPv6 through Laravel\u2019s inbuilt mechanism.<\/p>\n<p>This guide walked you through the simple process and undoubtedly helped you decipher the know-how for validating the IPv6 in Laravel.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Laravel 9 IPv6 validation example; Since IPv6 (Internet Protocol version 6) is the newest addition to Internet Protocol, It is way better than IPv4. It offers distinctive IP addresses essential [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":338,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,14],"tags":[],"class_list":["post-337","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-laravel","category-tutorial","clearfix"],"_links":{"self":[{"href":"https:\/\/247blogs.com\/wp\/wp-json\/wp\/v2\/posts\/337","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/247blogs.com\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/247blogs.com\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/247blogs.com\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/247blogs.com\/wp\/wp-json\/wp\/v2\/comments?post=337"}],"version-history":[{"count":1,"href":"https:\/\/247blogs.com\/wp\/wp-json\/wp\/v2\/posts\/337\/revisions"}],"predecessor-version":[{"id":703,"href":"https:\/\/247blogs.com\/wp\/wp-json\/wp\/v2\/posts\/337\/revisions\/703"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/247blogs.com\/wp\/wp-json\/wp\/v2\/media\/338"}],"wp:attachment":[{"href":"https:\/\/247blogs.com\/wp\/wp-json\/wp\/v2\/media?parent=337"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/247blogs.com\/wp\/wp-json\/wp\/v2\/categories?post=337"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/247blogs.com\/wp\/wp-json\/wp\/v2\/tags?post=337"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}