<?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: Md Anik Islam</title>
    <description>The latest articles on Forem by Md Anik Islam (@anik2069).</description>
    <link>https://forem.com/anik2069</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%2F1057379%2F75b7efac-05ed-4491-9f0d-d2570eb493fa.jpeg</url>
      <title>Forem: Md Anik Islam</title>
      <link>https://forem.com/anik2069</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/anik2069"/>
    <language>en</language>
    <item>
      <title>Droplet/VPS Configuration with Nginx with Https For Node and NextJs</title>
      <dc:creator>Md Anik Islam</dc:creator>
      <pubDate>Thu, 18 Apr 2024 03:57:03 +0000</pubDate>
      <link>https://forem.com/anik2069/dropletvps-configuration-with-nginx-with-https-for-node-and-nextjs-1f76</link>
      <guid>https://forem.com/anik2069/dropletvps-configuration-with-nginx-with-https-for-node-and-nextjs-1f76</guid>
      <description>&lt;p&gt;In the ever-evolving landscape of web development, efficient server configuration is paramount to ensuring optimal performance and scalability of applications. With the emergence of versatile technologies like MERN (MongoDB, Express.js, React.js, Node.js) stack for JavaScript-based applications and PHP for server-side scripting, developers are empowered to create dynamic and interactive web experiences. However, the efficacy of these applications greatly relies on the underlying server infrastructure.&lt;/p&gt;

&lt;p&gt;Enter Nginx, a high-performance web server renowned for its speed, scalability, and flexibility. Leveraging Nginx as the cornerstone of your Droplet/VPS (Virtual Private Server) configuration lays the foundation for a resilient and efficient hosting environment. This guide aims to walk you through the process of configuring Nginx to seamlessly accommodate both MERN and PHP applications on your Droplet/VPS.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Nginx?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Nginx's asynchronous, event-driven architecture makes it adept at handling concurrent connections with minimal resource consumption, making it an ideal choice for serving both static and dynamic content. Its robust feature set, including reverse proxying, load balancing, and SSL/TLS termination, empowers developers to optimize performance and security effortlessly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Get SSH Username, Password and Connect to server using terminal&lt;/strong&gt;&lt;br&gt;
If you are using vps from digital ocean then you need to first create a droplet according to your configuration and then click on your droplet and then you will find named console. After clicking on there you will find a terminal that directly connect to your server&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjjw6phav1s7c5pk3ba6g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjjw6phav1s7c5pk3ba6g.png" alt="Droplet Screenshoot" width="800" height="467"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If your using external one then open your terminal and hit&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh username@serverip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;then it take your password and give your password and login to your server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2 – Installing Nginx&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;sudo apt update
sudo apt install nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;run above command to install nginx&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3 – Adjusting the Firewall&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before testing Nginx, the firewall software needs to be adjusted to allow access to the service. Nginx registers itself as a service with ufw upon installation, making it straightforward to allow Nginx access.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo ufw app list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As demonstrated by the output, there are three profiles available for Nginx:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1rzwini2kxi3vsy6a5x5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1rzwini2kxi3vsy6a5x5.png" alt="Nginx Output" width="557" height="104"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Nginx Full: This profile opens both port 80 (normal, unencrypted web traffic) and port 443 (TLS/SSL encrypted traffic)&lt;br&gt;
Nginx HTTP: This profile opens only port 80 (normal, unencrypted web traffic)&lt;br&gt;
Nginx HTTPS: This profile opens only port 443 (TLS/SSL encrypted traffic)&lt;/p&gt;

&lt;p&gt;It is recommended that you enable the most restrictive profile that will still allow the traffic you’ve configured. Right now, we will only need to allow traffic on port 80.&lt;/p&gt;

&lt;p&gt;You can enable this by typing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo ufw allow 'Nginx HTTP'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can verify the change by typing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo ufw status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4 – Checking your Web Server&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We can check with the systemd init system to make sure the service is running by typing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;systemctl status nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmzom6yx44c0i66cpke9a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmzom6yx44c0i66cpke9a.png" alt="Nginx output" width="572" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;now hit your ip to your browser you will find nginx landing page&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5 — Installing Certbot&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The first step to using Let’s Encrypt to obtain an SSL certificate is to install the Certbot software on your server.&lt;/p&gt;

&lt;p&gt;Install Certbot and it’s Nginx plugin with apt:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install certbot python3-certbot-nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Step 6 — Confirming Nginx’s Configuration
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Certbot needs to be able to find the correct server block in your Nginx configuration for it to be able to automatically configure SSL. Specifically, it does this by looking for a server_name directive that matches the domain you request a certificate for.&lt;/p&gt;

&lt;p&gt;To check, open the configuration file for your domain using nano or your favorite text editor:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nano /etc/nginx/sites-available/example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Find the existing server_name line. It should look like this:&lt;/p&gt;

&lt;p&gt;...&lt;br&gt;
server_name example.com &lt;a href="http://www.example.com"&gt;www.example.com&lt;/a&gt;;&lt;br&gt;
...&lt;/p&gt;

&lt;p&gt;If it does, exit your editor and move on to the next step.&lt;/p&gt;

&lt;p&gt;If it doesn’t, update it to match. Then save the file, quit your editor, and verify the syntax of your configuration edits:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nginx -t
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you get an error, reopen the server block file and check for any typos or missing characters. Once your configuration file’s syntax is correct, reload Nginx to load the new configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl reload nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 7 — Allowing HTTPS Through the Firewall&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you have the ufw firewall enabled, as recommended by the prerequisite guides, you’ll need to adjust the settings to allow for HTTPS traffic. Luckily, Nginx registers a few profiles with ufw upon installation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo ufw status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To additionally let in HTTPS traffic, allow the Nginx Full profile and delete the redundant Nginx HTTP profile allowance:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo ufw allow 'Nginx Full'
sudo ufw delete allow 'Nginx HTTP'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 8 — Obtaining an SSL Certificate&lt;/strong&gt;&lt;br&gt;
Certbot provides a variety of ways to obtain SSL certificates through plugins. The Nginx plugin will take care of reconfiguring Nginx and reloading the config whenever necessary. To use this plugin, type the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo certbot --nginx -d example.com -d www.example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This runs certbot with the --nginx plugin, using -d to specify the domain names we’d like the certificate to be valid for.&lt;/p&gt;

&lt;p&gt;If this is your first time running certbot, you will be prompted to enter an email address and agree to the terms of service. After doing so, certbot will communicate with the Let’s Encrypt server, then run a challenge to verify that you control the domain you’re requesting a certificate for.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 8: Setting Up for MERN&lt;/strong&gt;&lt;br&gt;
Update and upgrade the packages on the droplet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt update &amp;amp;&amp;amp; sudo apt upgrade -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nginx is the tool that will handle all the routing to our Next.js application. Create a new Nginx configuration file for your Next.js application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nano /etc/nginx/sites-available/nextjs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Paste the following configuration, replacing server_name with your domain name or droplet IP address:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;server {
  listen 80;
  server_name YOUR_IP_ADDRESS;
  location / {
    proxy_pass http://localhost:3000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save and close the file. Create a symbolic link to enable the configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo ln -s /etc/nginx/sites-available/nextjs /etc/nginx/sites-enabled/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Test the Nginx configuration for any syntax errors:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo nginx -t
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now clone your git repo in your server. Then run&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Build the Next.js application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, start the Next.js application:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Your Next.js application is now deployed and accessible at your domain name or droplet IP address. To keep your application running in the background and automatically restart on crashes or server reboots, you should use a process manager like PM2&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 9: Setting Up PM2 Process Manager&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We ran npm start from within our Droplet. Sometimes this command may stop running for reasons like the server restarted or it needed to install updates. We will use a tool called PM2 to make sure that our Next.js application is always running. PM2 will even restart the Next.js application if it goes down.&lt;/p&gt;

&lt;p&gt;To install PM2 globally on your droplet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo npm install -g pm2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start the Next.js application using PM2:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pm2 start npm --name "nextjs" -- start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will generate a script that you can copy and paste into your terminal to enable PM2 to start on boot.&lt;/p&gt;

&lt;p&gt;Save the current PM2 processes:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;For NodeJS Run via PM2&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pm2 start app.js --name "my-express-app"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
In this section, I tried to complete all part related to VPS configuration for node and Next JS. Hopefully its find you good. If facing any problem, Comment section is open&lt;/p&gt;

</description>
      <category>nginx</category>
      <category>mern</category>
      <category>javascript</category>
      <category>vps</category>
    </item>
    <item>
      <title>Simple and Easiest Toast Notifications in Laravel: A Quick Guide</title>
      <dc:creator>Md Anik Islam</dc:creator>
      <pubDate>Fri, 06 Oct 2023 18:34:39 +0000</pubDate>
      <link>https://forem.com/anik2069/simple-and-easiest-toast-notifications-in-laravel-a-quick-guide-2dj6</link>
      <guid>https://forem.com/anik2069/simple-and-easiest-toast-notifications-in-laravel-a-quick-guide-2dj6</guid>
      <description>&lt;p&gt;Hi Artisan,&lt;br&gt;
What's up? Hope's all are good. Today, we'll explore the easiest way to show toast notifications in Laravel. We'll be using the popular JavaScript library called Toastr to achieve this.&lt;/p&gt;

&lt;p&gt;You can easily follow this for any laravel version. and for example i am using laravel 10.&lt;/p&gt;

&lt;h2&gt;
  
  
  Short Introduction of Toast:
&lt;/h2&gt;

&lt;p&gt;Toast notifications are a common feature in web applications that allow you to provide non-intrusive feedback or information to users. They typically appear as small, temporary messages that slide in from the top or bottom of the screen. In Laravel, you can easily implement toast notifications to enhance user experience and provide real-time updates.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step1 : Install a laravel Project
&lt;/h2&gt;

&lt;p&gt;In first step, If you haven't installed Laravel in your system then you can run bellow command and get fresh Laravel project.&lt;/p&gt;

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

composer create-project --prefer-dist laravel/laravel laravel-toast


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

&lt;/div&gt;
&lt;h2&gt;
  
  
  Step2 : Create Master Layout for Toast
&lt;/h2&gt;

&lt;p&gt;Go to Resource/views path and create a simple master layout like below &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 lang="en"&amp;gt;

&amp;lt;head&amp;gt;
    &amp;lt;meta http-equiv="content-type" content="text/html;charset=UTF-8" /&amp;gt;
    &amp;lt;meta charset="utf-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;title&amp;gt;  Management Solution.&amp;lt;/title&amp;gt;
    &amp;lt;link rel="shortcut icon" href="../img/favicon.ico"&amp;gt;
    &amp;lt;!--STYLESHEET--&amp;gt;
    @include('layouts.css')

    @stack('ex_js')
&amp;lt;/head&amp;gt;
&amp;lt;!--TIPS--&amp;gt;
&amp;lt;!--You may remove all ID or Class names which contain "demo-", they are only used for demonstration. --&amp;gt;

&amp;lt;body&amp;gt;
    &amp;lt;div id="container" class="effect mainnav-lg navbar-fixed mainnav-fixed"&amp;gt;
        &amp;lt;!--NAVBAR--&amp;gt;
        &amp;lt;!--===================================================--&amp;gt;
        @include('layouts.header')
        &amp;lt;!--===================================================--&amp;gt;
        &amp;lt;!--END NAVBAR--&amp;gt;
        &amp;lt;div class="boxed"&amp;gt;
            @yield('content')
            &amp;lt;!--===================================================--&amp;gt;
            &amp;lt;!--END CONTENT CONTAINER--&amp;gt;
            &amp;lt;!--MAIN NAVIGATION--&amp;gt;
            &amp;lt;!--===================================================--&amp;gt;
            @if (Auth::user()-&amp;gt;is_super == 1)
                @include('layouts.nav')
            @else
                @include('nav')
            @endif
            &amp;lt;!--===================================================--&amp;gt;
            &amp;lt;!--END MAIN NAVIGATION--&amp;gt;
            &amp;lt;!--END ASIDE--&amp;gt;
        &amp;lt;/div&amp;gt;
        &amp;lt;!-- FOOTER --&amp;gt;
        &amp;lt;!--===================================================--&amp;gt;
        &amp;lt;footer id="footer" style=" background-color: #A8A8A8; color: white;"&amp;gt;
            &amp;lt;!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --&amp;gt;
            &amp;lt;div class="hide-fixed pull-right pad-rgt"&amp;gt;Currently v2.0&amp;lt;/div&amp;gt;
            &amp;lt;!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --&amp;gt;
            &amp;lt;!-- Remove the class name "show-fixed" and "hide-fixed" to make the content always appears. --&amp;gt;
            &amp;lt;!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --&amp;gt;
            &amp;lt;p class="pad-lft"&amp;gt;&amp;amp;#0169; 2023 Technical support by &amp;lt;a href="https://www.techlozi.com/" target="_blank"
                    class="btn-link"&amp;gt;techlozi&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
        &amp;lt;/footer&amp;gt;
        &amp;lt;!--===================================================--&amp;gt;
        &amp;lt;!-- END FOOTER --&amp;gt;
        &amp;lt;!-- SCROLL TOP BUTTON --&amp;gt;
        &amp;lt;!--===================================================--&amp;gt;
        &amp;lt;button id="scroll-top" class="btn"&amp;gt;&amp;lt;i class="fa fa-chevron-up"&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/button&amp;gt;
        &amp;lt;!--===================================================--&amp;gt;
    &amp;lt;/div&amp;gt;

    @include('layouts.js')
    @include('layouts.custom_js')
    @stack('custom_js')
    @yield('scripts')

&amp;lt;/body&amp;gt;

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



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

&lt;/div&gt;
&lt;h2&gt;
  
  
  Step3 : Adding CDN Link
&lt;/h2&gt;

&lt;p&gt;In Head Section of Master layout add this below css cdn of Toast&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

 &amp;lt;link href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.css" rel="stylesheet"&amp;gt;



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

&lt;/div&gt;

&lt;p&gt;In end Section of Master layout add this below JS cdn of Toast&lt;/p&gt;

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

 &amp;lt;script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"&amp;gt;&amp;lt;/script&amp;gt;



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

&lt;/div&gt;
&lt;h2&gt;
  
  
  Step4 : Toast Message Script Configuration
&lt;/h2&gt;

&lt;p&gt;Adding this branch of code below JS cdn of Toast&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

 &amp;lt;script&amp;gt;
        @if (Session::has('message'))
            var type = "{{ Session::get('alert-type', 'info') }}"
            switch (type) {
                case 'info':

                    toastr.options.timeOut = 10000;
                    toastr.info("{{ Session::get('message') }}");
                    var audio = new Audio('audio.mp3');
                    audio.play();
                    break;
                case 'success':

                    toastr.options.timeOut = 10000;
                    toastr.success("{{ Session::get('message') }}");
                    var audio = new Audio('audio.mp3');
                    audio.play();

                    break;
                case 'warning':

                    toastr.options.timeOut = 10000;
                    toastr.warning("{{ Session::get('message') }}");
                    var audio = new Audio('audio.mp3');
                    audio.play();

                    break;
                case 'error':

                    toastr.options.timeOut = 10000;
                    toastr.error("{{ Session::get('message') }}");
                    var audio = new Audio('audio.mp3');
                    audio.play();

                    break;
            }
        @endif
    &amp;lt;/script&amp;gt;


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

&lt;/div&gt;

&lt;p&gt;You can modify style or popup time from here. And you can add more case from here as much you need&lt;/p&gt;

&lt;h2&gt;
  
  
  Step5 : Handle Message From Controller
&lt;/h2&gt;

&lt;p&gt;First I am creating a controller by using below command&lt;/p&gt;

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

php artisan make:controller BannerController


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

&lt;/div&gt;

&lt;p&gt;In this Controller i am writing a function which will update status of a banner and my code is below&lt;/p&gt;

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

   public function bannerStatus($bannerId, $status)
    {
        $banner = Bannner::find($bannerId);
        $banner-&amp;gt;status = $status;
        $banner-&amp;gt;save();

        $notification = array(
            'message' =&amp;gt; 'Successfully Done',
            'alert-type' =&amp;gt; 'success'
        );

        return redirect()-&amp;gt;back()-&amp;gt;with($notification);
    }



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

&lt;/div&gt;

&lt;p&gt;In this branch of code you will find a array name &lt;strong&gt;$notification&lt;/strong&gt; and there is two key here . One is &lt;strong&gt;Message or Notification&lt;/strong&gt; other one is which &lt;strong&gt;type of Alert&lt;/strong&gt; it it. Alert-type must be same as master layout script code. Other wise it will fail to work.&lt;/p&gt;

&lt;h2&gt;
  
  
  OutPut Example
&lt;/h2&gt;

&lt;p&gt;Here is some out screenshot ot toast.&lt;/p&gt;

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

   $notification = array(
            'message' =&amp;gt; 'Successfully Done',
            'alert-type' =&amp;gt; 'success'
        );


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

&lt;/div&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%2Fks3i5meltidp5b606640.png" 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%2Fks3i5meltidp5b606640.png" alt="Success"&gt;&lt;/a&gt;&lt;/p&gt;

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

      $notification = array(
            'message' =&amp;gt; 'Error Done',
            'alert-type' =&amp;gt; 'error'
        );


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

&lt;/div&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%2Fpo6e5bf1a2xflgluwywp.png" 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%2Fpo6e5bf1a2xflgluwywp.png" alt="Error "&gt;&lt;/a&gt;&lt;/p&gt;

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

      $notification = array(
            'message' =&amp;gt; 'Waring Done',
            'alert-type' =&amp;gt; 'warning'
        );


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

&lt;/div&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%2Fe03tca66ca1i6y67ixm9.png" 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%2Fe03tca66ca1i6y67ixm9.png" alt="warning"&gt;&lt;/a&gt;&lt;/p&gt;

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

      $notification = array(
            'message' =&amp;gt; 'Info Done',
            'alert-type' =&amp;gt; 'info'
        );


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

&lt;/div&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%2F6gvgayouwshnxkxnjeos.png" 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%2F6gvgayouwshnxkxnjeos.png" alt="info"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How To Export Unique Barcode to Excel In Laravel</title>
      <dc:creator>Md Anik Islam</dc:creator>
      <pubDate>Sun, 23 Apr 2023 19:33:26 +0000</pubDate>
      <link>https://forem.com/anik2069/how-to-export-unique-barcode-to-excel-in-laravel-2lma</link>
      <guid>https://forem.com/anik2069/how-to-export-unique-barcode-to-excel-in-laravel-2lma</guid>
      <description>&lt;p&gt;Hi Artisan,&lt;br&gt;
What's up? Hope's all are good. In this tutorial, I will give you an example to export barcode in excel in Laravel by using JavaScript. &lt;/p&gt;

&lt;p&gt;You can easily export barcode in laravel 5, laravel 6, laravel 7, laravel 8, laravel 9 and laravel 10 version.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Step 1&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In first step, If you haven't installed Laravel in your system then you can run bellow command and get fresh Laravel project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer create-project --prefer-dist laravel/laravel export-barcode
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Step 2&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Now we need a install a barcode package of laravel. there is so many barcode package we have for laravel. Among them you can use any one. In this case i am installing picqer/php-barcode-generator package for barcode generator, that way we can use it's method. So Open your terminal and run bellow command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer require picqer/php-barcode-generator
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Step 3&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In this step, we will create one route for testing example. So, let's add new route on that file.&lt;br&gt;
&lt;strong&gt;routes/web.php&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
Route::view('export-barcode', 'export-barcode');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we need to create export-barcode.blade.php for display bar code. so let's create blade file as like bellow code:&lt;/p&gt;

&lt;p&gt;resources/views/export-barcode.blade.php&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LO0jReCr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/egcxzyejul8vuntt0x3f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LO0jReCr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/egcxzyejul8vuntt0x3f.png" alt="export-barcode.blade.php" width="800" height="1107"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Step 4&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This is the main part of this tutorial. Here we will doing our main operation to export barcode to excel. Note that the generated barcodes are in base64 format. So whenever we need to export a barcode to excel. First need to save generate bar code to your local storage. Here is code save base64 image to local.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    @php
        $generatorPNG = new Picqer\Barcode\BarcodeGeneratorPNG();
        $somecode = time() . '.png'; //left as excersise for the reader.
        $baseImage = 'data:image/png;base64,' . base64_encode($generatorPNG-&amp;gt;getBarcode('000005263635', $generatorPNG::TYPE_CODE_128));

        $img = str_replace('data:image/png;base64,', '', $baseImage);
        $img = str_replace(' ', '+', $img);
        $data = base64_decode($img);

        $path = public_path() . '/barcode/' . $somecode;
        file_put_contents($path, $data);
    @endphp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After Saving The image to local use that saved path of image in Rendered Table. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Step 5&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Finally we need a js function which will export excel. Here is the below code of js Function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$(function() {
            $(".exportToExcel").click(function(event) {
                console.log("Exporting XLS");
                $("#studentTable").table2excel({
                    exclude: ".excludeThisClass",
                    name: $("#studentTable").data("tableName"),
                    filename: "StudentTable.xls",
                    preserveColors: false
                });
            });
        });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Don't forget to import below CDN link.&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;script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;script src="https://cdn.rawgit.com/rainabba/jquery-table2excel/1.1.0/dist/jquery.table2excel.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Output
&lt;/h2&gt;

&lt;p&gt;Here is the snapshot of our Output.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2dKEehZJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ln1i73vfkwul3mxvqro6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2dKEehZJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ln1i73vfkwul3mxvqro6.png" alt="Excel Output" width="652" height="518"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: If You don't want to save all the barcode in your local storage then you can hit Ajax request that delete all the barcode image after export. &lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>laravel</category>
      <category>excel</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
