<?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>DEV Community: Remon Hasan</title>
    <description>The latest articles on DEV Community by Remon Hasan (@remonhasan).</description>
    <link>https://dev.to/remonhasan</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%2F455181%2Fc673e0d0-d1f4-49d3-b033-5223d643fa72.png</url>
      <title>DEV Community: Remon Hasan</title>
      <link>https://dev.to/remonhasan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/remonhasan"/>
    <language>en</language>
    <item>
      <title>Laravel Route Model Binding : Simplifying Controller Logic</title>
      <dc:creator>Remon Hasan</dc:creator>
      <pubDate>Tue, 16 Apr 2024 09:31:04 +0000</pubDate>
      <link>https://dev.to/remonhasan/laravel-route-model-binding-simplifying-controller-logic-b1j</link>
      <guid>https://dev.to/remonhasan/laravel-route-model-binding-simplifying-controller-logic-b1j</guid>
      <description>&lt;p&gt;&lt;a href="https://gist.github.com/f3c4f184d3c2f9be70cdb5d57d79b2d7.git"&gt;Example on my Gist&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Laravel's &lt;a href="https://laravel.com/docs/11.x/routing#route-model-binding"&gt;Route Model Binding&lt;/a&gt; stands as a cornerstone feature, streamlining the interaction between routes and models within your application. It offers a seamless mechanism to automatically inject model instances into your routes based on specified parameters. This feature not only enhances code readability but also boosts developer productivity by eliminating the need for manual model retrieval.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding Route Model Binding
&lt;/h2&gt;

&lt;p&gt;At its core, Route Model Binding simplifies the process of retrieving model instances by associating them directly with route parameters. Consider a scenario where you're building a blogging platform using Laravel. You have a Post model representing individual blog posts, and you wish to create routes to display these posts based on their IDs.&lt;/p&gt;

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

&lt;p&gt;Let's delve into a practical example to grasp the essence of Route Model Binding. In your routes/web.php file, define a route to showcase individual posts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Route::get('/posts/{post}', 'PostController@show');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, {post} serves as a route parameter signifying the ID of the post.&lt;/p&gt;

&lt;p&gt;Next, within your PostController, craft the show method as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public function show(Post $post)
{
    return view('posts.show', ['post' =&amp;gt; $post]);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Observe that the show method takes a parameter $post, type-hinted with the Post model. Laravel intelligently resolves this parameter, automatically injecting the corresponding Post model instance based on the value of the {post} route parameter.&lt;/p&gt;

&lt;p&gt;Now you can access the posts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://localhost:8000/posts/1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Streamlining Controller Logic&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Through Route Model Binding, Laravel obviates the need for manual model retrieval within controller methods. This not only declutters your code but also enhances its expressiveness and maintainability. By seamlessly integrating model instances into your controllers, Laravel empowers developers to focus on implementing business logic rather than grappling with mundane data retrieval tasks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In conclusion, Laravel's Route Model Binding emerges as a powerful tool for simplifying controller logic and enhancing developer productivity. By seamlessly bridging routes and models, it facilitates cleaner, more expressive code, thereby fostering a more enjoyable and efficient development experience. Embrace Route Model Binding in your Laravel projects to unlock its full potential and streamline your application's architecture.&lt;/p&gt;

&lt;p&gt;Do you utilize Route Model Binding in your Laravel projects? Share your experiences and insights in the comments below and you can give star on my gist. Happy Learning !&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>php</category>
      <category>laravel</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Mastering State Management in React: Overcoming Common Challenges</title>
      <dc:creator>Remon Hasan</dc:creator>
      <pubDate>Tue, 02 Jan 2024 12:08:02 +0000</pubDate>
      <link>https://dev.to/remonhasan/mastering-state-management-in-react-overcoming-common-challenges-64d</link>
      <guid>https://dev.to/remonhasan/mastering-state-management-in-react-overcoming-common-challenges-64d</guid>
      <description>&lt;h1&gt;
  
  
  Introduction:
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://react.dev/learn/managing-state"&gt;State management&lt;/a&gt; is a fundamental aspect of React development, yet many developers face hurdles while effectively managing it within their applications. In this guide, we'll explore common challenges and provide solutions to empower developers in mastering state management in React.&lt;/p&gt;

&lt;h1&gt;
  
  
  Understanding State in React:
&lt;/h1&gt;

&lt;p&gt;In React, state represents the data that determines the behavior of components and their rendering. It's essential to distinguish between state and props: while props are immutable and passed from parent to child, state is mutable and managed within a component.&lt;/p&gt;

&lt;h1&gt;
  
  
  Common Challenges in State Management:
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;State Confusion:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { useState } from 'react';

const Counter = () =&amp;gt; {
  const [count, setCount] = useState(0);

  const increment = () =&amp;gt; {
    // Incorrect usage causing confusion
    setCount(count + 1); // This might not work as expected
  };

  return (
    &amp;lt;div&amp;gt;
      &amp;lt;p&amp;gt;Count: {count}&amp;lt;/p&amp;gt;
      &amp;lt;button onClick={increment}&amp;gt;Increment&amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};

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

&lt;/div&gt;



&lt;h1&gt;
  
  
  Solution:
&lt;/h1&gt;

&lt;p&gt;Utilize the functional update form to avoid dependency on the previous state.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const increment = () =&amp;gt; {
  setCount(prevCount =&amp;gt; prevCount + 1);
};

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Prop Drilling:&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Grandparent Component
const App = () =&amp;gt; {
  const [value, setValue] = useState('');

  return (
    &amp;lt;Parent value={value} setValue={setValue} /&amp;gt;
  );
};

// Parent Component
const Parent = ({ value, setValue }) =&amp;gt; {
  return (
    &amp;lt;Child value={value} setValue={setValue} /&amp;gt;
  );
};

// Child Component
const Child = ({ value, setValue }) =&amp;gt; {
  return (
    &amp;lt;Grandchild value={value} setValue={setValue} /&amp;gt;
  );
};

// Grandchild Component
const Grandchild = ({ value, setValue }) =&amp;gt; {
  return (
    &amp;lt;input
      value={value}
      onChange={e =&amp;gt; setValue(e.target.value)}
    /&amp;gt;
  );
};

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt; Implement React Context or lift the state up to the nearest common ancestor to avoid passing props through multiple layers.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Building a React-Redux Counter: Understanding State Management with Redux in React</title>
      <dc:creator>Remon Hasan</dc:creator>
      <pubDate>Tue, 19 Dec 2023 11:04:38 +0000</pubDate>
      <link>https://dev.to/remonhasan/building-a-react-redux-counter-understanding-state-management-with-redux-in-react-56c7</link>
      <guid>https://dev.to/remonhasan/building-a-react-redux-counter-understanding-state-management-with-redux-in-react-56c7</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--G4wq8Gow--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qcr3luhk57v1g42031bs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--G4wq8Gow--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qcr3luhk57v1g42031bs.png" alt="Redux Counter" width="800" height="351"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this post we will take a look at using Redux for managing the state in React apps. For that we'll make a simple redux counter project. Let's break down each part of the Redux implementation step by step:&lt;/p&gt;

&lt;p&gt;Source Code : &lt;a href="https://github.com/Remonhasan/react-redux-counter"&gt;Github&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Redux Basics
&lt;/h2&gt;

&lt;p&gt;Redux is a predictable state container for JavaScript apps. It helps manage the state of your application in a predictable way, making it easier to debug and understand how data changes over time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up the Folder Structure
&lt;/h2&gt;

&lt;h1&gt;
  
  
  Actions
&lt;/h1&gt;

&lt;p&gt;Actions are payloads of information that send data from your application to your Redux store. In the &lt;code&gt;actions&lt;/code&gt; folder:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;actionTypes.js&lt;/code&gt;: Defines action types as constants.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YOZErQSN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3fvs13iczf4a9rrnr8gb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YOZErQSN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3fvs13iczf4a9rrnr8gb.png" alt="Image description" width="800" height="301"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;counterActions.js&lt;/code&gt;: Contains action creator functions that return actions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ifFVbDqk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/afztjvp25mqt3z970udn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ifFVbDqk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/afztjvp25mqt3z970udn.png" alt="Image description" width="800" height="430"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Reducers
&lt;/h1&gt;

&lt;p&gt;Reducers specify how the application's state changes in response to actions sent to the store. In the &lt;code&gt;reducers&lt;/code&gt; folder:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;counterReducer.js&lt;/code&gt;: Defines how the state for the counter should change based on dispatched actions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SHRFMsS---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v9a4paj4yrr83w6y7y2o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SHRFMsS---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v9a4paj4yrr83w6y7y2o.png" alt="Image description" width="800" height="749"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;index.js&lt;/code&gt;: Combines all reducers using &lt;code&gt;combineReducers&lt;/code&gt; from Redux.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bezzr8p3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eygyv4bovjy01ht541ft.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bezzr8p3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eygyv4bovjy01ht541ft.png" alt="Image description" width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Store
&lt;/h1&gt;

&lt;p&gt;The store holds the state of the application. In the &lt;code&gt;store&lt;/code&gt; folder: &lt;code&gt;index.js&lt;/code&gt;: Creates the Redux store using the combined reducers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2oFIxwNx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0e3yfhb9fl0u0xmtvb93.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2oFIxwNx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0e3yfhb9fl0u0xmtvb93.png" alt="Image description" width="800" height="325"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up Redux in App
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;App.js&lt;/code&gt; : Wraps the entire app with the Redux &lt;code&gt;Provider&lt;/code&gt;, which makes the Redux store available to any nested components.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--V2zC0LX3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/grxtgsx5xm9nyur4hbld.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--V2zC0LX3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/grxtgsx5xm9nyur4hbld.png" alt="Image description" width="800" height="729"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuring Redux in the App
&lt;/h2&gt;

&lt;h1&gt;
  
  
  &lt;code&gt;components/Counter.js&lt;/code&gt;
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;This is a functional component connected to Redux using the connect function from &lt;code&gt;react-redux&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;mapStateToProps&lt;/code&gt; is a function that maps parts of the Redux state to the component's props.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;mapDispatchToProps&lt;/code&gt; is an object that maps action creators to props.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;connect&lt;/code&gt; connects the component to the Redux store, allowing it to access the state and dispatch actions.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kFtQFmLK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1spe4quiw0fei8a3tb42.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kFtQFmLK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1spe4quiw0fei8a3tb42.png" alt="Image description" width="800" height="710"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Running the App
&lt;/h2&gt;

&lt;h1&gt;
  
  
  Starting the Application
&lt;/h1&gt;

&lt;p&gt;Run &lt;code&gt;npm start&lt;/code&gt; to start the React application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Actions&lt;/strong&gt; are dispatched to describe something that happened (like "INCREMENT" or "DECREMENT").&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reducers&lt;/strong&gt; describe how the application's state changes in response to actions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Store&lt;/strong&gt; holds the application's state.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Connecting Components&lt;/strong&gt; allows them to access the Redux store's state and dispatch actions.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This breakdown covers the foundational parts of a simple Redux setup in a React application. Understanding these sections will help you grasp how Redux manages state and data flow in a React application. If any specific part needs further explanation, feel free to ask!&lt;/p&gt;

</description>
      <category>redux</category>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Preserving Special Characters in Query Parameters: A React Journey</title>
      <dc:creator>Remon Hasan</dc:creator>
      <pubDate>Sun, 05 Nov 2023 06:32:58 +0000</pubDate>
      <link>https://dev.to/remonhasan/preserving-special-characters-in-query-parameters-a-react-journey-oko</link>
      <guid>https://dev.to/remonhasan/preserving-special-characters-in-query-parameters-a-react-journey-oko</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the world of web development, handling query parameters and URLs is a fundamental task. However, there are situations where special characters within these parameters can lead to unexpected challenges. One such issue I encountered involved the loss of special characters within a &lt;code&gt;redirect_uri&lt;/code&gt;. In this article, I'll walk you through the problem, the solution, and how to implement it in your React application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Problem&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine you have a URL like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://localhost:3001/en/auth/login?servicename=Grant&amp;amp;redirect_uri=http://localhost:3000/bsmrnt/buy-ticket?code=ETN&amp;amp;start_time=10:00:00

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

&lt;/div&gt;



&lt;p&gt;In this URL, the &lt;code&gt;redirect_uri&lt;/code&gt; contains special characters, specifically the &amp;amp; symbol. When extracting this parameter in a React app using &lt;code&gt;queryParams&lt;/code&gt;, you might run into issues as the &lt;code&gt;&amp;amp;&lt;/code&gt; character separates query parameters.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Initial Approach&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;My initial approach was to use the common method of extracting query parameters in React:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const queryParams = new URLSearchParams(window.location.search);
const redirectUri = queryParams.get('redirect_uri');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, this approach resulted in &lt;code&gt;redirectUri&lt;/code&gt; containing only part of the URL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://localhost:3000/bsmrnt/buy-ticket?code=ETN

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

&lt;/div&gt;



&lt;p&gt;As you can see, the &lt;code&gt;&amp;amp;start_time=10:00:00&lt;/code&gt; part is missing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Solution&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To preserve the complete &lt;code&gt;redirect_uri&lt;/code&gt;, I found a creative solution using JavaScript's regular expressions and &lt;code&gt;window.location.href&lt;/code&gt;. Here's the code:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XAIDnO8m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sbtxo26c754t445lhs36.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XAIDnO8m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sbtxo26c754t445lhs36.png" alt="Image description" width="800" height="228"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We first obtain the complete URL using &lt;code&gt;window.location.href&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Then, we use a regular expression to extract the &lt;code&gt;redirect_uri&lt;/code&gt; and capture everything that follows it.&lt;/li&gt;
&lt;li&gt;Finally, we ensure that we have the complete &lt;code&gt;redirect_uri&lt;/code&gt; by checking both the regular expression match and the &lt;code&gt;queryParams&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Implementation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To implement this solution in your React app, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Retrieve the &lt;code&gt;currentURL&lt;/code&gt; and use the regular expression to capture the complete &lt;code&gt;redirect_uri&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use the captured &lt;code&gt;redirectUri&lt;/code&gt; as needed in your application.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here's a sample implementation inside a &lt;code&gt;useEffect&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4tkyVXpY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cmpjmzomycf5jfqsslft.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4tkyVXpY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cmpjmzomycf5jfqsslft.png" alt="Image description" width="800" height="259"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This ensures that you store the complete &lt;code&gt;redirect_uri&lt;/code&gt; without losing any special characters.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Handling special characters in query parameters can be tricky, but with the right approach, you can ensure they are preserved. In this article, we explored a real-world problem and a creative solution using JavaScript and React. By implementing this technique, you can preserve the integrity of your URLs and provide a seamless user experience.&lt;/p&gt;

&lt;p&gt;If you've ever struggled with lost query parameters, give this solution a try. Let's solve the mystery of preserving special characters in query parameters together!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>webdev</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Cronjob Schedule: Automating Old Data Cleanup with Laravel</title>
      <dc:creator>Remon Hasan</dc:creator>
      <pubDate>Thu, 19 Oct 2023 09:39:58 +0000</pubDate>
      <link>https://dev.to/remonhasan/safeguarding-your-database-automating-old-data-cleanup-with-laravel-55a2</link>
      <guid>https://dev.to/remonhasan/safeguarding-your-database-automating-old-data-cleanup-with-laravel-55a2</guid>
      <description>&lt;p&gt;For implementation check in : &lt;a href="https://github.com/Remonhasan/cron-purge"&gt;Github Repository&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;I have faced a problem selecting a seat in a hall where the seat reserve timeout is supposed to be five minutes.  Basically, any visitor can reserve his/her seat for at least five minutes. After that the seat will be available for all. &lt;/p&gt;

&lt;h2&gt;
  
  
  Problem
&lt;/h2&gt;

&lt;p&gt;I have stored the selected seat on a &lt;code&gt;reserve_seats&lt;/code&gt; table. Where I store all of the visitors' selected seats by their &lt;code&gt;user_id&lt;/code&gt;. The main concern is it is needed to auto delete the seat when the five minutes will be passed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_ggh9e4w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5cjsry44xrcj002hhyjd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_ggh9e4w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5cjsry44xrcj002hhyjd.png" alt="Selected Seats in Hall Layout" width="768" height="579"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;Laravel has come up with a great solution of deleting the old data by managing schedule work. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Create a Laravel Artisan Command:&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;php artisan make:command ClearOldData&lt;/code&gt;&lt;br&gt;
This will create a new command file in the &lt;code&gt;app/Console/Commands&lt;/code&gt; directory.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Define the Command Logic:&lt;/strong&gt;&lt;br&gt;
Open the &lt;code&gt;ClearOldData.php&lt;/code&gt; file in the &lt;code&gt;app/Console/Commands&lt;/code&gt;directory and define the logic for deleting old data. In this case, we'll assume you have a table named &lt;code&gt;your_table_name&lt;/code&gt; and you want to delete records older than 5 minutes.&lt;br&gt;
&lt;/p&gt;

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

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Carbon\Carbon;

class ClearOldData extends Command
{
    protected $signature = 'clear:old-data';
    protected $description = 'Delete old data from the table.';

    public function __construct()
    {
        parent::__construct();
    }

    public function handle()
    {
        // Calculate the date and time 5 minutes ago
        $fiveMinutesAgo = Carbon::now()-&amp;gt;subMinutes(5);

        // Replace 'your_table_name' with the name of your table
        \DB::table('your_table_name')-&amp;gt;where('created_at', '&amp;lt;', $fiveMinutesAgo)-&amp;gt;delete();

        $this-&amp;gt;info('Old data has been deleted.');
    }
}

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Define the Task Scheduling:&lt;/strong&gt;&lt;br&gt;
Open the &lt;code&gt;app/Console/Kernel.php&lt;/code&gt; file and define the scheduling logic. Add the following code to the schedule method in the Kernel class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;protected function schedule(Schedule $schedule)
{
    $schedule-&amp;gt;command('clear:old-data')-&amp;gt;everyMinute();
}

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;4. Run the Scheduler:&lt;/strong&gt;&lt;br&gt;
To activate the task scheduler, you'll need to add a &lt;code&gt;cron&lt;/code&gt; job that runs Laravel's scheduler every minute. In your server's &lt;code&gt;cron&lt;/code&gt; file, add the following line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;* * * * * cd /path-to-your-laravel-project &amp;amp;&amp;amp; php artisan schedule:run &amp;gt;&amp;gt; /dev/null 2&amp;gt;&amp;amp;1

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;5. Run the Scheduler:&lt;/strong&gt;&lt;br&gt;
To manually run the scheduler, you can execute the following command:&lt;br&gt;
&lt;code&gt;php artisan schedule:run&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now, the &lt;code&gt;clear:old-data&lt;/code&gt; command will run every minute and delete records older than 5 minutes from your specified table. Adjust the table name and timing as needed for your specific use case.&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>laravelschedule</category>
      <category>cronjob</category>
    </item>
    <item>
      <title>uses of useNavigate instead of useHistory</title>
      <dc:creator>Remon Hasan</dc:creator>
      <pubDate>Mon, 06 Jun 2022 10:24:25 +0000</pubDate>
      <link>https://dev.to/remonhasan/uses-of-usenavigate-instead-of-usehistory-5fg6</link>
      <guid>https://dev.to/remonhasan/uses-of-usenavigate-instead-of-usehistory-5fg6</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Github Repository : &lt;br&gt;
&lt;a href="https://github.com/Remonhasan/react-ecomBox"&gt;Github&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The useHistory hook gives you access to the history instance. In General useHistory is used for redirect to particular route after fetch api data or anything else with history. We used it as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const history = useHistory()
history.push("/path")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;sometimes it fails to give you the access to the history instance. As per, useNavigate is the best way to redirect the particular route with your history instance. Here we go:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const history = useNavigate();
history("/path");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OMv1Sljx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tzeeabvu26avzybfjbh9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OMv1Sljx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tzeeabvu26avzybfjbh9.png" alt="Image description" width="800" height="749"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>hooks</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Laravel 8 REST API Authentication with Sanctum</title>
      <dc:creator>Remon Hasan</dc:creator>
      <pubDate>Sun, 16 May 2021 16:07:57 +0000</pubDate>
      <link>https://dev.to/remonhasan/laravel-8-rest-api-authentication-with-sanctum-ie8</link>
      <guid>https://dev.to/remonhasan/laravel-8-rest-api-authentication-with-sanctum-ie8</guid>
      <description>&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%2Fgfzap5yn1tr0nd9husrg.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%2Fgfzap5yn1tr0nd9husrg.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Source Code
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://github.com/Remonhasan/product-api-laravel-sanctum-spa" rel="noopener noreferrer"&gt;Github&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Laravel Sanctum, formerly known as Airlock, is a Laravel package created for the authentication of Single Page Applications (SPAs), mobile applications, and basic token-based APIs. It can be used to issue API Tokens to your users and authenticate Single Page Applications using Laravel's session.&lt;br&gt;
we are going to create product api. For testing we will use the postman.&lt;/p&gt;

&lt;h1&gt;
  
  
  Model and Migration
&lt;/h1&gt;

&lt;p&gt;First, we have to create a product model,migration,controller as like:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;php artisan make:model Product -m&lt;/code&gt;&lt;br&gt;
&lt;code&gt;php artisan make:controller ProductController --api&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Create the fields as like: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff9jedf1vtxl1frtuda49.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%2Ff9jedf1vtxl1frtuda49.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Migrate: Before migrate you should create the database in env file and connect to the MySql server or others you prefer.&lt;/p&gt;

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

&lt;h1&gt;
  
  
  Route
&lt;/h1&gt;

&lt;p&gt;Second, we have to create a resource route in api.php as like:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Route::resource('products', ProductController::class);&lt;/code&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Controller Functions
&lt;/h1&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%2Fzqck352t9zaliwii1vcg.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%2Fzqck352t9zaliwii1vcg.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fndg1b2w6i9b9ikh1xl7y.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%2Fndg1b2w6i9b9ikh1xl7y.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fopkxai77maanguq3ezrc.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%2Fopkxai77maanguq3ezrc.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Postman Test
&lt;/h1&gt;

&lt;p&gt;Create:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3j1q3vrs5tt0gvizv934.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%2F3j1q3vrs5tt0gvizv934.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Update:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl7y2hnl44ivdebya78tc.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%2Fl7y2hnl44ivdebya78tc.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Validation: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu9mu2rczlwb06ob9cfqo.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%2Fu9mu2rczlwb06ob9cfqo.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Delete:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feaj7v8r6pq12e8igm1rg.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%2Feaj7v8r6pq12e8igm1rg.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Search by Name:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4p9objvvua7gbsufy37m.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%2F4p9objvvua7gbsufy37m.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Get by ID:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F811tbj025ears4ubri4b.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%2F811tbj025ears4ubri4b.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Sanctum Authentication and Access Token Generation
&lt;/h1&gt;

&lt;p&gt;Install Sanctum:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;composer require laravel/sanctum&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Vendor Publish for access token migration:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Migrate:&lt;/p&gt;

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

&lt;h1&gt;
  
  
  setup
&lt;/h1&gt;

&lt;p&gt;Go to app, then kernel.php and add the given lines in api array section. also for query you can follow &lt;a href="https://laravel.com/docs/8.x/sanctum#introduction" rel="noopener noreferrer"&gt;laravel Sanctum Documentation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faq5gadrhj5tamt2a5vgw.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%2Faq5gadrhj5tamt2a5vgw.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Add to User Model: Go to User.php and add the lines:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;use Laravel\Sanctum\HasApiTokens;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;use HasFactory, Notifiable, HasApiTokens;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Create a group route function which will include the protected routes:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fup7irnixn1cw7ed9i9ar.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%2Fup7irnixn1cw7ed9i9ar.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Create Controller
&lt;/h1&gt;

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

&lt;h1&gt;
  
  
  Register Function
&lt;/h1&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%2Fd6wrb7kkedky8vbtz8xk.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%2Fd6wrb7kkedky8vbtz8xk.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Postman Test:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxm4ggvyc77lzhojf0tq2.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%2Fxm4ggvyc77lzhojf0tq2.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Get Product access by token:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxa8mr7pn7ogf0u5qrant.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%2Fxa8mr7pn7ogf0u5qrant.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now add logout: After logout the token will be deleted.&lt;/p&gt;

&lt;p&gt;`public function logout(Request $request) {&lt;br&gt;
        auth()-&amp;gt;user()-&amp;gt;tokens()-&amp;gt;delete();&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    return [
        'message' =&amp;gt; 'Logged out'
    ];
}` 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Create logout route:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Route::post('/logout', [AuthController::class, 'logout']);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Postman Test:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxijo7blp5okctsuhce1l.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%2Fxijo7blp5okctsuhce1l.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Login
&lt;/h1&gt;

&lt;p&gt;Create route for login as like:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Route::post('/login', [AuthController::class, 'login']);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Login Function:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr790gkxwqxlotwthwtq6.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%2Fr790gkxwqxlotwthwtq6.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Logged in:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuji72qg0fazrjxrxw7bp.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%2Fuji72qg0fazrjxrxw7bp.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  All Public and Protected Route
&lt;/h1&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%2Fwwxxbmps4np1z0rbkdld.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%2Fwwxxbmps4np1z0rbkdld.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>restapi</category>
      <category>php</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Shopping Cart Laravel 8: part 03</title>
      <dc:creator>Remon Hasan</dc:creator>
      <pubDate>Fri, 14 May 2021 12:14:45 +0000</pubDate>
      <link>https://dev.to/remonhasan/shopping-cart-laravel-8-part-03-2khf</link>
      <guid>https://dev.to/remonhasan/shopping-cart-laravel-8-part-03-2khf</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1kVAjYyn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tiqk6lduwh8bgunh0l2d.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1kVAjYyn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tiqk6lduwh8bgunh0l2d.jpg" alt="Alt Text" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Source Code
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://github.com/Remonhasan/ecommerce-laravel8"&gt;Github&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Add to cart
&lt;/h1&gt;

&lt;p&gt;Now we have to pick the add to cart of product by using wire bind as like:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;wire:click.prevent="store({{$product-&amp;gt;id}},'{{$product-&amp;gt;name}}',{{$product-&amp;gt;regular_price}})"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Additionally, we can use the method of count() for checking there is any product or not! For that we can use the loop like:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;@if(Cart::count()&amp;gt;0)&lt;br&gt;
// go for product&lt;br&gt;
else&lt;br&gt;
No Products&lt;br&gt;
@endif&lt;/code&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Fetch product image from database
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;src="{{asset('assets/images/products')}}/{{$item-&amp;gt;model-&amp;gt;image}}"&lt;/code&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Route action
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;href="{{route('product.details',['slug'=&amp;gt;$item-&amp;gt;model-&amp;gt;slug])}}"&lt;/code&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Rest of the functions of building cart package
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Subtotall&lt;/li&gt;
&lt;li&gt;Total&lt;/li&gt;
&lt;li&gt;Tax&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oantnaRF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2syjwg0jvbw0uloxst32.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oantnaRF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2syjwg0jvbw0uloxst32.png" alt="Alt Text" width="800" height="103"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Shopping Cart Laravel 8: Part 02</title>
      <dc:creator>Remon Hasan</dc:creator>
      <pubDate>Thu, 13 May 2021 10:50:36 +0000</pubDate>
      <link>https://dev.to/remonhasan/shopping-cart-laravel-8-part-02-iei</link>
      <guid>https://dev.to/remonhasan/shopping-cart-laravel-8-part-02-iei</guid>
      <description>&lt;h1&gt;
  
  
  Source Code
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://github.com/Remonhasan/ecommerce-laravel8"&gt;Github&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Component Create
&lt;/h1&gt;

&lt;p&gt;Create your own component for cart,product details and shop.&lt;br&gt;
Then create a store function in shopcomponent.php as like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--apTJ3Zxk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/poy9y115twvstr5ltdei.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--apTJ3Zxk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/poy9y115twvstr5ltdei.png" alt="Alt Text" width="765" height="131"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;pass the parameters to the product page as like by adding:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;wire:click.prevent="store({{$product-&amp;gt;id}},'{{$product-&amp;gt;name}}',{{$product-&amp;gt;regular_price}})"&lt;/code&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Shopping Cart Laravel 8 : Part 1</title>
      <dc:creator>Remon Hasan</dc:creator>
      <pubDate>Wed, 12 May 2021 16:25:11 +0000</pubDate>
      <link>https://dev.to/remonhasan/shopping-cart-laravel-8-part-1-gdg</link>
      <guid>https://dev.to/remonhasan/shopping-cart-laravel-8-part-1-gdg</guid>
      <description>&lt;h1&gt;
  
  
  Source Code
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://github.com/Remonhasan/ecommerce-laravel8"&gt;Github&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Shopping Cart
&lt;/h1&gt;

&lt;p&gt;A shopping cart is a piece of software that keeps the record of the items a buyer has 'picked up' from the online store.&lt;/p&gt;

&lt;h1&gt;
  
  
  Shopping Cart Package
&lt;/h1&gt;

&lt;p&gt;By using the &lt;a href="https://github.com/hardevine/LaravelShoppingcart"&gt;hardevine shopping cart&lt;/a&gt; we can easily implement that.&lt;/p&gt;

&lt;h1&gt;
  
  
  Installation
&lt;/h1&gt;

&lt;p&gt;Go to your newly created project directory and run the command:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;composer require hardevine/shoppingcart&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;h1&gt;
  
  
  Configuration Setup
&lt;/h1&gt;

&lt;p&gt;Go to app.php and set the given line to the providers[ ] section like:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Gloudemans\Shoppingcart\ShoppingcartServiceProvider::class&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Add one more to the aliases[ ] as like:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;‘Cart’ =&amp;gt; Gloudemans\Shoppingcart\Facades\Cart::class&lt;/code&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Publishing the Package
&lt;/h1&gt;

&lt;p&gt;&lt;code&gt;Php artisan vendor:publish --provider="Gloudeman\ShoppingcartServiceProvider" --tag="config"&lt;/code&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Miller Robin Primality Test</title>
      <dc:creator>Remon Hasan</dc:creator>
      <pubDate>Thu, 08 Oct 2020 10:34:15 +0000</pubDate>
      <link>https://dev.to/remonhasan/miller-robin-primality-test-3hl</link>
      <guid>https://dev.to/remonhasan/miller-robin-primality-test-3hl</guid>
      <description>&lt;p&gt;Similar to Fermat primality test, Miller-Rabin primality test could only determine if a number is a probable prime.&lt;/p&gt;

&lt;p&gt;It is based on a basic principle where if , but , then  is composite.&lt;/p&gt;

&lt;p&gt;The algorithm in simple steps can be written as,&lt;/p&gt;

&lt;p&gt;Given a number () for which primality is to be tested,&lt;br&gt;
Step 1: Find &lt;br&gt;
Step 2: Choose  in range &lt;br&gt;
Step 3: Compute . If  is ,  can be prime.&lt;br&gt;
Step 4: Compute . If ,  is composite.&lt;br&gt;
If ,  is prime.&lt;br&gt;
Step 5: Repeat Step 4 for  times.&lt;br&gt;
Step 6: If neither  or  appeared for ,  is composite.&lt;/p&gt;

</description>
      <category>programming</category>
    </item>
    <item>
      <title>Manage Categorial Data of Dataset</title>
      <dc:creator>Remon Hasan</dc:creator>
      <pubDate>Tue, 06 Oct 2020 09:08:01 +0000</pubDate>
      <link>https://dev.to/remonhasan/manage-categorial-data-of-dataset-1m55</link>
      <guid>https://dev.to/remonhasan/manage-categorial-data-of-dataset-1m55</guid>
      <description>&lt;h1&gt;
  
  
  encoding categorial data
&lt;/h1&gt;

&lt;h1&gt;
  
  
  import LabelEncoder Class of Sklearn
&lt;/h1&gt;

&lt;p&gt;from sklearn.preprocessing import LabelEncoder&lt;/p&gt;

&lt;h1&gt;
  
  
  create object of LabelEncoder
&lt;/h1&gt;

&lt;p&gt;labelencoder_X = LabelEncoder()&lt;/p&gt;

&lt;h1&gt;
  
  
  labeling the object
&lt;/h1&gt;

&lt;p&gt;labelencoder_X.fit_transform(X[:, 0])&lt;/p&gt;

&lt;h1&gt;
  
  
  now put it into the country column
&lt;/h1&gt;

&lt;p&gt;X[:, 0] = labelencoder_X.fit_transform(X[:, 0])&lt;/p&gt;

&lt;h1&gt;
  
  
  Then Print
&lt;/h1&gt;

&lt;p&gt;print(X)&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>datascience</category>
    </item>
  </channel>
</rss>
