<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[A4AnthonyDev]]></title><description><![CDATA[Hello, my name is Anthony. I am a full stack web developer based in Nigeria. I pretty much fell in love with coding and now it is time to give technical writing]]></description><link>https://blog.a4anthony.com</link><generator>RSS for Node</generator><lastBuildDate>Fri, 05 Jun 2026 03:23:50 GMT</lastBuildDate><atom:link href="https://blog.a4anthony.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Publishing vue components to npm]]></title><description><![CDATA[As we all know, vue components are meant to be reused. This process is rather easy when working with a single application but how about using the same vue components across multiple vue applications? copy and paste? This can work but it becomes very ...]]></description><link>https://blog.a4anthony.com/publishing-vue-components-to-npm</link><guid isPermaLink="true">https://blog.a4anthony.com/publishing-vue-components-to-npm</guid><category><![CDATA[Vue.js]]></category><category><![CDATA[vue]]></category><category><![CDATA[npm]]></category><category><![CDATA[Frontend Development]]></category><category><![CDATA[UI Design]]></category><dc:creator><![CDATA[Anthony Akro]]></dc:creator><pubDate>Sun, 28 Mar 2021 20:39:25 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1616958669718/xVWU7D_Nf.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>As we all know, vue components are meant to be reused. This process is rather easy when working with a single application but how about using the same vue components across multiple vue applications? copy and paste? This can work but it becomes very inefficient in terms of maintenance. Best practice? The best practice so far is to package the vue component and publish it to npm in order to have to a central entry point to the component which makes changes available to all applications making use of the component. In this article, I'll put together some guidelines and resources to get this up and running.</p>
<h3 id="heading-creating-the-component">Creating the component</h3>
<p>To begin with you'll need to create your vue application which will host your reusable component. While building out your component, you'll want to do this in partial isolation of the vue environment. This means you'll not be able to preview what you're building and also know if it works fine. To make up for this, you can make use of <a target="_blank" href="https://storybook.js.org/docs/vue/get-started/introduction">Storybook</a>. Storybook is an open source platform that is used to build UI components in isolation. It has amazing features and I 100% recommend it. It also has a pretty decent community to help you get started.</p>
<h3 id="heading-packaging-the-component">Packaging the component</h3>
<p>In order to publish your component to npm, you'll to need to first package the component into distributable builds. Here's reference articles that explain how to do this properly.</p>
<p>For vue 2:</p>
<p><a target="_blank" href="https://vuejs.org/v2/cookbook/packaging-sfc-for-npm.html">https://vuejs.org/v2/cookbook/packaging-sfc-for-npm.html</a></p>
<p>For vue 3:</p>
<p><a target="_blank" href="https://v3.vuejs.org/guide/single-file-component.html#building-with-rollup">https://v3.vuejs.org/guide/single-file-component.html#building-with-rollup</a></p>
<h3 id="heading-testing-out-the-packaged-component">Testing out the packaged component</h3>
<p>Before publishing to npm, you'll want to test out your component in a sample vue application to be sure everything plugs in nicely. To do this, you can use the script below to build and package your component into an installable .tgz file, move the .tgz file to the sample vue application and also install the the packaged component via npm</p>
<pre><code class="lang-plaintext">#!/usr/bin/env sh

# abort on errors
set -e

# build
npm run build

npm pack

cp vue-packaged-component-0.1.0.tgz ~/sample-vue-application-path

cd ~/sample-vue-application-path/

npm i vue-packaged-component-0.1.0.tgz
</code></pre>
<p>After running the script, your component will be available in the sample vue application and you can test it out there.</p>
<h3 id="heading-publishing-to-npm">Publishing to npm</h3>
<p>This is pretty much an easy step. Put together a workflow that works for you and the rest is just a repetitive procedure. Well, you don't have to think too much about putting this together, this article <a target="_blank" href="https://zellwk.com/blog/publish-to-npm/">How to publish packages to npm (the way the industry does things)</a> will show you how to get through this step.</p>
<p>You're done! your component will be published to npm and ready to be used in multiple applications. To view a project I've created and published using this workflow you can check out <a target="_blank" href="https://github.com/a4anthony/vue-inline-svgs">https://github.com/a4anthony/vue-inline-svgs</a> and <a target="_blank" href="https://www.npmjs.com/package/vue-inline-svgs">https://www.npmjs.com/package/vue-inline-svgs</a>.</p>
<p>Thank you for your time and I hope this turns out really helpful.</p>
]]></content:encoded></item><item><title><![CDATA[Why I love Coding...]]></title><description><![CDATA[Why do I love coding? To be honest that's a tough question because it's just something I always find myself doing unconsciously for hours. It is something that took me 4 years to eventually start, Shoutout to procrastination but yeah I've been coding...]]></description><link>https://blog.a4anthony.com/why-i-love-coding</link><guid isPermaLink="true">https://blog.a4anthony.com/why-i-love-coding</guid><category><![CDATA[General Programming]]></category><category><![CDATA[General Advice]]></category><category><![CDATA[coding]]></category><dc:creator><![CDATA[Anthony Akro]]></dc:creator><pubDate>Wed, 20 Jan 2021 18:30:46 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1611167413056/71vEeLdfX.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Why do I love coding? To be honest that's a tough question because it's just something I always find myself doing unconsciously for hours. It is something that took me 4 years to eventually start, Shoutout to procrastination but yeah I've been coding for about a year plus now and I've quite loved my life since then.</p>
<p>How has the journey been? While I initially thought coding was rocket science you know, it looked difficult at the time. How on earth was I going to learn and master "HTML"? A lot of things tried to discourage me, that's pretty much normal with life. Eventually, I started and I realised that yeah, coding is actually rocket science, I was right. It is difficult, time consuming and literally puts on edge every single time. Anytime I hear someone that has been coding say "I hate coding" my reply is always "tell me about your bug". Without a doubt such statements are instigated by a "baby bug" you've come across while coding. At the end of the day, it is still difficult. There's a whole bunch of languages, frameworks etc that are out there with very large and quite complex documentations and in today's world, you need to know at least 5 of them to stand a good position in anything. So you see, the main difficulty is from the time consumption learning these technologies come with but once you can master that, everything becomes easy. Everything else is literally, like writing a story and giving instructions to your computer. I started off with W3Schools and FreeCodeCamp working on html and css and from there I did a little bit of Bootstrap. My learning then became projects-based and I actually think that's a good way to go. I picked up a blog series with PHP and MySQL by CodewithAwa and that's how I got to learn PHP (I also got to read the official documentation and and useful articles in my free time as well). Also at that point I realised that BackEnd web dev was going to be my thing. FrontEnd is still amazing but you know, not all of us are really on the creative side of things when it comes to designs and yeah, I'm still efficient with FrontEnd web dev but I like to keep it simple. Everything pretty much kicked off from there, I was coding literally everyday and looping through the internet until I stumbled on Laravel(people told me about is as well) and you know that "new technology, who is this?" vibe. I jumped on it. I learnt it through Laracasts, the contents there are amazing and basically since then all my PHP works have been through Laravel. You'll meet people that'll try to discourage you from using frameworks but you know, just use a framework and see how easy it makes the work for you and get to decide for yourself(preferably learn the language natively first). I'll more like stop here for now, I’ll talk more on it in future posts. Just start off with the right language or tutorial and everything else with come with experience. </p>
<p>Going professional? Well until now, I’ve had only one job interview and that was for a Backend web dev position. I didn't get the job but in all honesty, the interview went well. I picked out so many things from the requirements and the questions that were thrown at me and they have contributed a lot to my growth in the last couple months. One issue I face is the fact I studied Civil Engineering in University and not Computer Science(or some other tech related program). So yeah, convincing people that you can design a building also build a website becomes quite difficult. Regardless, I'll keep on pushing and improving myself, the goal is to work in a professional environment one day and hopefully that'll happen soon.</p>
<p>Challenges? My major challenge is "Nigeria". The internet and electricity services are quite terrible. I spend so much monthly on data and I definitely do not get my money’s worth. The electricity is quite seasonal. Good occasionally, decent and you know, very bad occasionally as well. Imagine having an idea that could change the world but hey, you need to wait for power to come back on. Quite frustrating if you ask me but regardless, I need to do what I have to do to progress. Also my networking hasn't been great. You know, two programmers are better than one one except one of them doesn't include comments in their code. So yeah, I'll like to connect with more programmers than will be beneficial to my growth and vice versa. If you’re interested, you can leave a message for me here.</p>
<p>Benefits so far? Coding has changed my perspective of life. You know, I fix a 1 week old bug and I realise that yeah, I can achieve anything I put my mind to. It also gives me this mindset that there's always a solution to everything(not doing "x" can also be a solution to the problems that comes with doing "x"). It's made me feel good with myself, I feel ready to change the world.</p>
<p>My advice or opinions? Do NOT try to put everything in your head, just know where you can go to for certain information and you'll be fine. Don't jump on every new technology that comes out, well except you want to. Most of them will actually slow you down and they don't get to meet up to expectations. Code a lot, read a lot. Try to to have a reason attached to every decision you make and also try not to leave projects abandoned.</p>
<p>Build &gt; Complete &gt; Ship   </p>
<p>Remember, if David Okon stopped coding because of the issues he faced when he started he wouldn't be where he is today. I don't know who David Okon is and I'm guessing you don't as well but you get my point. No matter what, do not give up.</p>
]]></content:encoded></item><item><title><![CDATA[My 2021 Budget!!!]]></title><description><![CDATA[My 2021 Budget! Not about money though. I feel budget could be anything depending on the context. I think I'm right, I mean I hope so.
With that being said, My 2021 Budget.
My 2020?
I'll be honest(it is pretty obvious though), 2020 was really tough. ...]]></description><link>https://blog.a4anthony.com/my-2021-budget</link><guid isPermaLink="true">https://blog.a4anthony.com/my-2021-budget</guid><category><![CDATA[programing]]></category><category><![CDATA[writing]]></category><dc:creator><![CDATA[Anthony Akro]]></dc:creator><pubDate>Fri, 01 Jan 2021 18:20:16 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1609521983397/9qfvnaQ8w.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>My 2021 Budget! Not about money though. I feel budget could be anything depending on the context. I think I'm right, I mean I hope so.
With that being said, My 2021 Budget.</p>
<h3 id="heading-my-2020">My 2020?</h3>
<p>I'll be honest(it is pretty obvious though), 2020 was really tough. Besides the covid surprise, I still tried to keep things going at my own pace but oh well, that didn't exactly turn out well but... but... I tried. I started the year with just html, css and little bit of php and here's how it turned out,</p>
<ol>
<li>I became proficient with  <a target="_blank" href="https://laravel.com/">Laravel</a>.</li>
<li>Built and worked with a couple api's.</li>
<li>Used a few Google services(location api's, analytics etc).</li>
<li>Built an e-commerce store(not yet fully in production).</li>
<li>Server setup from scratch on  <a target="_blank" href="https://www.digitalocean.com/">Digital Ocean</a>  using nginx.</li>
<li>Worked with a couple front end frameworks mainly  <a target="_blank" href="https://vuejs.org/">vuejs</a>  and  <a target="_blank" href="https://nuxtjs.org/">nuxtjs</a> . They are definitely amazing.</li>
<li>Got 3 job rejections. Sad but I think I'm amazing.</li>
<li>Battled with Wordpress at some point.</li>
<li>Built a Laravel package for generating and managing discount coupons.</li>
<li>I made constant efforts to organise my projects workflow using  <a target="_blank" href="https://trello.com/">Trello</a>.</li>
<li>Worked on a few projects using  <a target="_blank" href="https://www.djangoproject.com/">Django</a>.</li>
</ol>
<p>There's probably a few that I've missed out but I think I did amazing still. The sad part still is that the outcome didn't exactly match the effort but we move!</p>
<h3 id="heading-my-2021">My 2021?</h3>
<p>Well, I personally feel my coding journey so far has been a little distorted. So for this year, I'll like to be a little more purposely. I'll like to focus a lot more on open source, it looks amazing and I'll also like to learn a couple new languages and frameworks(nodejs, python, tailwindcss etc). I'm also open and looking forward to joining a team and building amazing projects together. It'll definitely be amazing if I get to speak at a tech event and also attend one. Lastly, this is my year of technical writing, hopefully.</p>
<p>I've tried to keep this as simple as possible and also realistic. I hope this year turns out amazing.</p>
<p>Looking forward to my next post!</p>
]]></content:encoded></item><item><title><![CDATA[Laravel 7 autopopulate dropdown using Ajax]]></title><description><![CDATA[Todays tutorial will be on how to auto-populate a dropdown according to a preselected dropdown on Laravel using Ajax. 
This tutorial is also available on github.
First of all, we’ll create a new Laravel project(I’m assuming you already have composer ...]]></description><link>https://blog.a4anthony.com/laravel-7-autopopulate-dropdown-using-ajax</link><guid isPermaLink="true">https://blog.a4anthony.com/laravel-7-autopopulate-dropdown-using-ajax</guid><category><![CDATA[PHP]]></category><category><![CDATA[Ajax]]></category><category><![CDATA[jQuery]]></category><category><![CDATA[Laravel]]></category><dc:creator><![CDATA[Anthony Akro]]></dc:creator><pubDate>Tue, 08 Sep 2020 08:23:47 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1599554048213/M9Gy27Yf4.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Todays tutorial will be on how to auto-populate a dropdown according to a preselected dropdown on Laravel using Ajax. </p>
<p>This tutorial is also available on github.</p>
<p>First of all, we’ll create a new Laravel project(I’m assuming you already have composer installed).You could call the project anything but I’ll just go with “autopopulate”.</p>
<pre><code>composer <span class="hljs-keyword">create</span>-<span class="hljs-keyword">project</span> laravel/laravel autopopulate
</code></pre><p>Then open the .env file and adjust the database connection settings to match your database name and credentials.</p>
<pre><code><span class="hljs-attr">DB_CONNECTION</span>=mysql
<span class="hljs-attr">DB_HOST</span>=<span class="hljs-number">127.0</span>.<span class="hljs-number">0.1</span>
<span class="hljs-attr">DB_PORT</span>=<span class="hljs-number">3306</span>
<span class="hljs-attr">DB_DATABASE</span>=autopopulate
<span class="hljs-attr">DB_USERNAME</span>=root
<span class="hljs-attr">DB_PASSWORD</span>=
</code></pre><p>For this tutorial, I’m going to using Countries and States. </p>
<p>Let’s create out model and migrations file for both.</p>
<p>Run</p>
<pre><code>php artisan <span class="hljs-built_in">make</span>:model Country -m
</code></pre><p>and then run</p>
<pre><code>php artisan <span class="hljs-built_in">make</span>:model State -m
</code></pre><p>For the country migrations file. </p>
<pre><code>Schema::create(
    <span class="hljs-string">'countries'</span>,
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-params">(Blueprint $table)</span> </span>{
        $table-&gt;id();
        $table-&gt;string(<span class="hljs-string">'name'</span>);
        $table-&gt;timestamps();
    }
);
</code></pre><p>For the state migrations file.</p>
<pre><code>Schema::create(
    <span class="hljs-string">'states'</span>,
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-params">(Blueprint $table)</span> </span>{
        $table-&gt;id();
        $table-&gt;string(<span class="hljs-string">'name'</span>);
        $table-&gt;integer(<span class="hljs-string">'country_id'</span>);
        $table-&gt;timestamps();
    }
);
</code></pre><p>We will create dummy data for both in our database. </p>
<p>Let’s create our factories for both.</p>
<p>Run</p>
<pre><code>php artisan <span class="hljs-built_in">make</span>:factory CountryFactory
</code></pre><p>and then run</p>
<pre><code>php artisan <span class="hljs-built_in">make</span>:factory StateFactory
</code></pre><p>For the country factory </p>
<pre><code><span class="php"><span class="hljs-meta">&lt;?php</span>

<span class="hljs-comment">/** <span class="hljs-doctag">@var</span> \Illuminate\Database\Eloquent\Factory $factory */</span>

<span class="hljs-keyword">use</span> <span class="hljs-title">App</span>\<span class="hljs-title">Country</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">Faker</span>\<span class="hljs-title">Generator</span> <span class="hljs-title">as</span> <span class="hljs-title">Faker</span>;

$factory-&gt;define(
    Country::class,
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-params">(Faker $faker)</span> </span>{
        <span class="hljs-keyword">return</span> [
            <span class="hljs-string">'name'</span> =&gt; $faker-&gt;word
        ];
    }
);</span>
</code></pre><p>For the state factory</p>
<pre><code><span class="php"><span class="hljs-meta">&lt;?php</span>

<span class="hljs-comment">/** <span class="hljs-doctag">@var</span> \Illuminate\Database\Eloquent\Factory $factory */</span>

<span class="hljs-keyword">use</span> <span class="hljs-title">App</span>\<span class="hljs-title">State</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">Faker</span>\<span class="hljs-title">Generator</span> <span class="hljs-title">as</span> <span class="hljs-title">Faker</span>;

$factory-&gt;define(
    State::class,
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-params">(Faker $faker)</span> </span>{
        <span class="hljs-keyword">return</span> [
            <span class="hljs-string">'name'</span> =&gt; $faker-&gt;word
        ];
    }
);</span>
</code></pre><p>In the database seeder</p>
<pre><code><span class="php"><span class="hljs-meta">&lt;?php</span>

<span class="hljs-keyword">use</span> <span class="hljs-title">App</span>\<span class="hljs-title">Country</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">App</span>\<span class="hljs-title">State</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">Illuminate</span>\<span class="hljs-title">Database</span>\<span class="hljs-title">Seeder</span>;

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">DatabaseSeeder</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Seeder</span>
</span>{
    <span class="hljs-comment">/**
     * Seed the application's database.
     *
     * <span class="hljs-doctag">@return</span> void
     */</span>
    <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">run</span><span class="hljs-params">()</span>
    </span>{
        $countries =  factory(Country::class, <span class="hljs-number">20</span>)-&gt;create();
        $countries-&gt;each(
            <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-params">($country)</span> </span>{
                factory(State::class, <span class="hljs-number">35</span>)-&gt;create([<span class="hljs-string">'country_id'</span> =&gt; $country-&gt;id]);
            }
        );
    }
}</span>
</code></pre><p>Then run</p>
<pre><code><span class="hljs-attribute">php</span> artisan migrate
</code></pre><p>and run </p>
<pre><code><span class="hljs-selector-tag">php</span> <span class="hljs-selector-tag">artisan</span> <span class="hljs-selector-tag">db</span><span class="hljs-selector-pseudo">:seed</span>
</code></pre><p>At this point, your database has been populate with dummy data.</p>
<p>Then let’s create our controller to handle all our requests.  </p>
<p>You can give your controller any name that suits your project</p>
<pre><code>php artisan <span class="hljs-built_in">make</span>:controller HomeController
</code></pre><p>Open your web.php file to register routes</p>
<pre><code>Route::<span class="hljs-keyword">get</span>(<span class="hljs-string">'/'</span>, <span class="hljs-string">'HomeController@index'</span>);
Route::<span class="hljs-keyword">get</span>(<span class="hljs-string">'/state/{countryId}'</span>, <span class="hljs-string">'HomeController@getState'</span>);
</code></pre><p>In your Controller</p>
<pre><code><span class="php"><span class="hljs-meta">&lt;?php</span>

<span class="hljs-keyword">namespace</span> <span class="hljs-title">App</span>\<span class="hljs-title">Http</span>\<span class="hljs-title">Controllers</span>;

<span class="hljs-keyword">use</span> <span class="hljs-title">App</span>\<span class="hljs-title">Country</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">App</span>\<span class="hljs-title">State</span>;

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">HomeController</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Controller</span>
</span>{
    <span class="hljs-comment">/**
     * Display page with all countries
     *
     * <span class="hljs-doctag">@return</span> Illuminate\View\View
     * <span class="hljs-doctag">@author</span> Anthony Akro &lt;anthonygakro<span class="hljs-doctag">@gmail</span>.com&gt; [a4anthony]
     */</span>
    <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">index</span><span class="hljs-params">()</span>
    </span>{
        $countries = Country::all();
        <span class="hljs-keyword">return</span> view(<span class="hljs-string">'welcome'</span>, [<span class="hljs-string">'countries'</span> =&gt; $countries]);
    }
    <span class="hljs-comment">/**
     * Retrieves state details from database
     *
     * <span class="hljs-doctag">@param</span> int $countryId
     *
     * <span class="hljs-doctag">@return</span> Illuminate\Http\Response
     * <span class="hljs-doctag">@author</span> Anthony Akro &lt;anthonygakro<span class="hljs-doctag">@gmail</span>.com&gt; [a4anthony]
     */</span>
    <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getState</span><span class="hljs-params">($countryId)</span>
    </span>{
        <span class="hljs-keyword">if</span> (!$countryId) {
            $html = <span class="hljs-string">'&lt;option value=""&gt;'</span> . trans(<span class="hljs-string">'global.pleaseSelect'</span>) . <span class="hljs-string">'&lt;/option&gt;'</span>;
        } <span class="hljs-keyword">else</span> {
            $html = <span class="hljs-string">'&lt;option value="'</span> . <span class="hljs-string">'"&gt;'</span> . <span class="hljs-string">'--- Select Sub Category ---'</span> . <span class="hljs-string">'&lt;/option&gt;'</span>;
            $states = State::where(<span class="hljs-string">'country_id'</span>, $countryId)-&gt;get();

            <span class="hljs-keyword">foreach</span> ($states <span class="hljs-keyword">as</span> $state) {
                $html .= <span class="hljs-string">'&lt;option value="'</span> . $state-&gt;id . <span class="hljs-string">'"&gt;'</span> . $state-&gt;name . <span class="hljs-string">'&lt;/option&gt;'</span>;
            }
        }

        <span class="hljs-keyword">return</span> response()-&gt;json([<span class="hljs-string">'html'</span> =&gt; $html]);
    }
}</span>
</code></pre><p>In your welcome.blade.php file in the the Resources &gt; view folder</p>
<pre><code><span class="hljs-meta">&lt;!DOCTYPE html&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">"{{ str_replace('_', '-', app()-&gt;getLocale()) }}"</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">"utf-8"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"viewport"</span> <span class="hljs-attr">content</span>=<span class="hljs-string">"width=device-width, initial-scale=1"</span>&gt;</span>

    <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Laravel Autopopulate<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>

    <span class="hljs-comment">&lt;!-- Fonts --&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"https://fonts.googleapis.com/css?family=Nunito:200,600"</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">"stylesheet"</span>&gt;</span>

    <span class="hljs-comment">&lt;!-- jquery --&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"</span>&gt;</span><span class="undefined"></span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>

    <span class="hljs-comment">&lt;!-- bootstrap --&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">"stylesheet"</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"</span> <span class="hljs-attr">integrity</span>=<span class="hljs-string">"sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"</span> <span class="hljs-attr">crossorigin</span>=<span class="hljs-string">"anonymous"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"</span> <span class="hljs-attr">integrity</span>=<span class="hljs-string">"sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"</span> <span class="hljs-attr">crossorigin</span>=<span class="hljs-string">"anonymous"</span>&gt;</span><span class="undefined"></span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>

    <span class="hljs-comment">&lt;!-- Styles --&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><span class="css">
        <span class="hljs-selector-tag">html</span>,
        <span class="hljs-selector-tag">body</span> {
            <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#fff</span>;
            <span class="hljs-attribute">color</span>: <span class="hljs-number">#636b6f</span>;
            <span class="hljs-attribute">font-family</span>: <span class="hljs-string">'Nunito'</span>, sans-serif;
            <span class="hljs-attribute">font-weight</span>: <span class="hljs-number">200</span>;
            <span class="hljs-attribute">height</span>: <span class="hljs-number">100vh</span>;
            <span class="hljs-attribute">margin</span>: <span class="hljs-number">0</span>;
        }

        <span class="hljs-selector-class">.full-height</span> {
            <span class="hljs-attribute">height</span>: <span class="hljs-number">100vh</span>;
        }

        <span class="hljs-selector-class">.flex-center</span> {
            <span class="hljs-attribute">align-items</span>: center;
            <span class="hljs-attribute">display</span>: flex;
            <span class="hljs-attribute">justify-content</span>: center;
        }

        <span class="hljs-selector-class">.position-ref</span> {
            <span class="hljs-attribute">position</span>: relative;
        }

        <span class="hljs-selector-class">.top-right</span> {
            <span class="hljs-attribute">position</span>: absolute;
            <span class="hljs-attribute">right</span>: <span class="hljs-number">10px</span>;
            <span class="hljs-attribute">top</span>: <span class="hljs-number">18px</span>;
        }

        <span class="hljs-selector-class">.content</span> {
            <span class="hljs-attribute">text-align</span>: center;
        }

        <span class="hljs-selector-class">.title</span> {
            <span class="hljs-attribute">font-size</span>: <span class="hljs-number">84px</span>;
        }

        <span class="hljs-selector-class">.links</span>&gt;<span class="hljs-selector-tag">a</span> {
            <span class="hljs-attribute">color</span>: <span class="hljs-number">#636b6f</span>;
            <span class="hljs-attribute">padding</span>: <span class="hljs-number">0</span> <span class="hljs-number">25px</span>;
            <span class="hljs-attribute">font-size</span>: <span class="hljs-number">13px</span>;
            <span class="hljs-attribute">font-weight</span>: <span class="hljs-number">600</span>;
            <span class="hljs-attribute">letter-spacing</span>: .<span class="hljs-number">1rem</span>;
            <span class="hljs-attribute">text-decoration</span>: none;
            <span class="hljs-attribute">text-transform</span>: uppercase;
        }

        <span class="hljs-selector-class">.m-b-md</span> {
            <span class="hljs-attribute">margin-bottom</span>: <span class="hljs-number">30px</span>;
        }
    </span><span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"flex-center position-ref full-height"</span>&gt;</span>
        @if (Route::has('login'))
        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"top-right links"</span>&gt;</span>
            @auth
            <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"{{ url('/home') }}"</span>&gt;</span>Home<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
            @else
            <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"{{ route('login') }}"</span>&gt;</span>Login<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>

            @if (Route::has('register'))
            <span class="hljs-tag">&lt;<span class="hljs-name">a</span> <span class="hljs-attr">href</span>=<span class="hljs-string">"{{ route('register') }}"</span>&gt;</span>Register<span class="hljs-tag">&lt;/<span class="hljs-name">a</span>&gt;</span>
            @endif
            @endauth
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
        @endif

        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"content"</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"title m-b-md"</span>&gt;</span>
                Laravel Autopopulate dropdown
            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>

            <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">style</span>=<span class="hljs-string">"padding:5rem;"</span>&gt;</span>
                <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"row"</span>&gt;</span>
                    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"col-6"</span>&gt;</span>
                        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"form-group"</span>&gt;</span>
                            <span class="hljs-tag">&lt;<span class="hljs-name">select</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"country"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"country"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"form-control"</span>&gt;</span>
                                <span class="hljs-tag">&lt;<span class="hljs-name">option</span> <span class="hljs-attr">value</span>=<span class="hljs-string">""</span>&gt;</span>-- select country --<span class="hljs-tag">&lt;/<span class="hljs-name">option</span>&gt;</span>
                                @foreach ($countries as $country)
                                <span class="hljs-tag">&lt;<span class="hljs-name">option</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"{{$country-&gt;id}}"</span>&gt;</span>{{$country-&gt;name}}<span class="hljs-tag">&lt;/<span class="hljs-name">option</span>&gt;</span>
                                @endforeach
                            <span class="hljs-tag">&lt;/<span class="hljs-name">select</span>&gt;</span>
                        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
                    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
                    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"col-6"</span>&gt;</span>
                        <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"form-group"</span>&gt;</span>
                            <span class="hljs-tag">&lt;<span class="hljs-name">select</span> <span class="hljs-attr">name</span>=<span class="hljs-string">""</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"state"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"form-control"</span> <span class="hljs-attr">disabled</span>&gt;</span>
                                <span class="hljs-tag">&lt;<span class="hljs-name">option</span> <span class="hljs-attr">value</span>=<span class="hljs-string">""</span>&gt;</span>-- select state --<span class="hljs-tag">&lt;/<span class="hljs-name">option</span>&gt;</span>
                            <span class="hljs-tag">&lt;/<span class="hljs-name">select</span>&gt;</span>
                        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
                    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
                <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
            <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>



    <span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">
        $(<span class="hljs-built_in">document</span>).ready(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
            $.ajaxSetup({
                headers: {
                    <span class="hljs-string">'X-CSRF-TOKEN'</span>: $(<span class="hljs-string">'meta[name="csrf-token"]'</span>).attr(<span class="hljs-string">'content'</span>)
                }
            });

            $(<span class="hljs-string">"#country"</span>).change(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>) </span>{
                <span class="hljs-built_in">console</span>.log($(<span class="hljs-keyword">this</span>).val());
                $.ajax({
                    url: <span class="hljs-string">"/state/"</span> + $(<span class="hljs-keyword">this</span>).val(),
                    method: <span class="hljs-string">'GET'</span>,
                    success: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">data</span>) </span>{
                        $(<span class="hljs-string">'#state'</span>).prop(<span class="hljs-string">'disabled'</span>, <span class="hljs-literal">false</span>);
                        $(<span class="hljs-string">'#state'</span>).html(data.html);
                    }
                });
            });
        });
    </span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>

<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre><p>To test,  run</p>
<pre><code><span class="hljs-attribute">php</span> artisan serve
</code></pre><p>and open the url below in your browser</p>
<pre><code>http:<span class="hljs-comment">//localhost:8000</span>
</code></pre><p>I hope this helped.</p>
]]></content:encoded></item></channel></rss>