<?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: Viktor Le</title>
    <description>The latest articles on DEV Community by Viktor Le (@viktorle1294).</description>
    <link>https://dev.to/viktorle1294</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%2F1432664%2F985e3ce4-dadf-4b2f-b6e8-b42df7744722.png</url>
      <title>DEV Community: Viktor Le</title>
      <link>https://dev.to/viktorle1294</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/viktorle1294"/>
    <language>en</language>
    <item>
      <title>-&gt;cursor() or -&gt; chunk()</title>
      <dc:creator>Viktor Le</dc:creator>
      <pubDate>Fri, 20 Mar 2026 08:41:52 +0000</pubDate>
      <link>https://dev.to/viktorle1294/-cursor-or-chunk-1dca</link>
      <guid>https://dev.to/viktorle1294/-cursor-or-chunk-1dca</guid>
      <description>&lt;p&gt;In Laravel, the cursor() method is used to iterate through large database datasets efficiently by keeping only a single record in memory at a time. Unlike get(), which loads the entire result set into an array, cursor() uses PHP generators to yield records one by one.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Basic Usage
&lt;/h3&gt;

&lt;p&gt;You can call cursor() at the end of an Eloquent or Query Builder chain. It returns a LazyCollection instance that you can loop through.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;App\Models\User&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;foreach&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'active'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Process one user at a time&lt;/span&gt;
    &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$user&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Key Characteristics
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Single Query Execution&lt;/strong&gt;: Unlike chunk(), which executes a new query for every batch of records, cursor() executes only one SQL query against the database.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory Efficiency&lt;/strong&gt;: It significantly reduces memory usage because it doesn't build a massive collection of all retrieved objects in PHP memory.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lazy Collections&lt;/strong&gt;: Starting from Laravel 6.0, cursor() returns a LazyCollection, allowing you to chain collection methods like filter(), map(), and each() without loading everything at once.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Eager Loading Limitation&lt;/strong&gt;: Using with() with cursor() can be inefficient because Laravel may still need to load all parent IDs to perform the eager loading query, potentially negating some memory benefits.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Comparison with Other Methods
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fwlt6arquqevstxesjn6k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fwlt6arquqevstxesjn6k.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;While cursor() is extremely memory-efficient, Laravel still includes chunk() because they solve different problems. Use chunk() when you need to perform batch operations (like updating records) or load relationships, and use cursor() when memory is your absolute top priority and you only need to read data.&lt;/p&gt;

&lt;h3&gt;
  
  
  When to use each
&lt;/h3&gt;

&lt;p&gt;The right choice depends on your specific task:&lt;/p&gt;

&lt;h4&gt;
  
  
  Use chunk() for batch updates or heavy processing.
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Why&lt;/strong&gt;: It processes data in groups (e.g., 1,000 at a time), which is faster for database operations because it minimizes overhead per record compared to a cursor.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Safeguard&lt;/strong&gt;: Use chunkById() if you are updating the same records you are querying to avoid skipping or repeating data.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Use cursor() for massive datasets (1M+ records) or streaming.
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Why&lt;/strong&gt;: It fetches one record at a time using a single query, keeping memory usage constant regardless of the total result size.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Best for&lt;/strong&gt;: Simple exports (like generating a large CSV) or read-only loops where you don't need to load many related models.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Use each() for simple iteration on smaller collections.
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Note&lt;/strong&gt;: In the context of large datasets, each() is often used as a method on a chunk or collection. If you call Model::all()-&amp;gt;each(), you still load everything into memory first, which is dangerous for large sets.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>laravel</category>
      <category>databasequery</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>What is OCR Pre-fill?</title>
      <dc:creator>Viktor Le</dc:creator>
      <pubDate>Fri, 19 Dec 2025 18:08:35 +0000</pubDate>
      <link>https://dev.to/viktorle1294/what-is-ocr-pre-fill-4h0f</link>
      <guid>https://dev.to/viktorle1294/what-is-ocr-pre-fill-4h0f</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;OCR Pre-fill is a technology that uses Optical Character Recognition to automatically extract data from images or scanned documents (like IDs, invoices, forms) and instantly fill those details into digital forms or fields, significantly speeding up data entry, improving accuracy, and boosting efficiency in processes like onboarding, accounting, and customer service. It works by converting visual text into machine-readable data, allowing systems to populate fields like names, addresses, amounts, and dates without manual typing.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  How it Works
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Image Capture: A user scans or uploads a document (e.g., takes a photo of an ID).&lt;/li&gt;
&lt;li&gt;Pre-processing: The software cleans the image (deskews, removes noise) to enhance text recognition.&lt;/li&gt;
&lt;li&gt;OCR Extraction: An OCR engine identifies and extracts text, recognizing specific fields based on document type (e.g., name, date, total amount).&lt;/li&gt;
&lt;li&gt;Data Mapping: The extracted text is mapped to corresponding fields in a digital form.&lt;/li&gt;
&lt;li&gt;Form Pre-fill: The form fields are automatically populated with the extracted data.&lt;/li&gt;
&lt;li&gt;Validation (Optional): The system can validate the data for accuracy before final submission.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Key Benefits
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Saves Time &amp;amp; Cost: Automates manual data entry, reducing labor and processing time.&lt;/li&gt;
&lt;li&gt;Increases Accuracy: Minimizes human errors associated with manual input, especially with AI-driven improvements.&lt;/li&gt;
&lt;li&gt;Improves User Experience: Makes mobile applications and digital processes smoother and faster.&lt;/li&gt;
&lt;li&gt;Streamlines Workflows: Integrates seamlessly into systems for quicker document processing.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Common Use Cases
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Insurance &amp;amp; Banking (BFSI): Processing claims, customer onboarding, identity verification.&lt;/li&gt;
&lt;li&gt;Hospitality &amp;amp; Tourism: Digitizing registration forms and guest information.&lt;/li&gt;
&lt;li&gt;Accounting: Automating invoice and bill processing.&lt;/li&gt;
&lt;li&gt;Mobile Apps: Filling out forms by scanning IDs or other documents.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  OCR references
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://ocr.space" rel="noopener noreferrer"&gt;https://ocr.space&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.miteksystems.com" rel="noopener noreferrer"&gt;https://www.miteksystems.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://extend.ai" rel="noopener noreferrer"&gt;https://extend.ai&lt;/a&gt;&lt;br&gt;
&lt;a href="https://eastgate-software.com" rel="noopener noreferrer"&gt;https://eastgate-software.com&lt;/a&gt;&lt;br&gt;
&lt;a href="https://formtify.app/ocr-landing" rel="noopener noreferrer"&gt;https://formtify.app/ocr-landing&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>ocr</category>
      <category>paperwork</category>
      <category>software</category>
    </item>
    <item>
      <title>How to revert a committed &amp; pushed file</title>
      <dc:creator>Viktor Le</dc:creator>
      <pubDate>Tue, 09 Sep 2025 02:16:39 +0000</pubDate>
      <link>https://dev.to/viktorle1294/how-to-revert-a-committed-pushed-file-3508</link>
      <guid>https://dev.to/viktorle1294/how-to-revert-a-committed-pushed-file-3508</guid>
      <description>&lt;p&gt;If you've already committed the changes and want to revert the FooFile.php file to its original state without affecting other changes in your branch, you can follow these steps:&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Identify the Commt:
&lt;/h2&gt;

&lt;p&gt;First, identify the commit where the file was last in its desired state. You can use the following command to view the commit history for the file.&lt;/p&gt;

&lt;p&gt;Note: the commit hash of the commit where the file was last correct.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Revert the File to a Specific Commit:
&lt;/h2&gt;

&lt;p&gt;Use the following command to revert the file to the state it was in a specific commit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout &amp;lt;commit-hash&amp;gt; -- FooFile.php
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Commit the Reversion:
&lt;/h2&gt;

&lt;p&gt;After reverting the file, you need to commit this change to your branch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add FooFile.php
git commit -m "Revert FooFile.php to its original state"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Push the Changes:
&lt;/h2&gt;

&lt;p&gt;Finally, push the changes to your remote repository:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>How to setup Amazon S3 Compatible Filesystems - MinIO on MacOS for Laravel Application</title>
      <dc:creator>Viktor Le</dc:creator>
      <pubDate>Wed, 25 Jun 2025 11:26:47 +0000</pubDate>
      <link>https://dev.to/viktorle1294/how-to-setup-on-macos-amazon-s3-compatible-filesystems-miniio-in-laravel-ja</link>
      <guid>https://dev.to/viktorle1294/how-to-setup-on-macos-amazon-s3-compatible-filesystems-miniio-in-laravel-ja</guid>
      <description>&lt;p&gt;By default, your application's filesystems configuration file contains a disk configuration for the s3 disk. In addition to using this disk to interact with Amazon S3, you may use it to interact with any S3-compatible file storage service , and MiniIO is the greate choice here.&lt;/p&gt;

&lt;p&gt;Let's say, the .env file has this block&lt;br&gt;
&lt;/p&gt;

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

AWS_ACCESS_KEY_ID=access_key
AWS_SECRET_ACCESS_KEY=secrete_key
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=xxxxxxx
AWS_ENDPOINT=xxxxxxx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are two ways to setup MiniIO locally&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Set up directly in the localhost
Easy step with 1 command
&lt;/li&gt;
&lt;/ol&gt;

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

&lt;/div&gt;



&lt;p&gt;Then launch the MinIO Server by running the following command. If desired, you can replace ~/data with another localtion of Storage to read, write and delete access for the MinIO instance&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export MINIO_CONFIG_ENV_FILE=/etc/default/minio
minio server ~/data --address :9001 ### API (S3 compatible)
minio server ~/data --console-address :9002 ### Web UI (User Interface)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After you run these above commands, it will print out&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Status:         1 Online, 0 Offline.
API: http://192.168.2.100:9001  http://127.0.0.1:9001
RootUser: myminioadmin
RootPass: minio-secret-key-change-me
Console: http://192.168.2.100:9002 http://127.0.0.1:9002
RootUser: myminioadmin
RootPass: minio-secret-key-change-me

Command-line: https://min.io/docs/minio/linux/reference/minio-mc.html
   $ mc alias set myminio http://10.0.2.100:9001 myminioadmin minio-secret-key-change-me

Documentation: https://min.io/docs/minio/linux/index.html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, you have &lt;code&gt;access_key&lt;/code&gt; and &lt;code&gt;secrete_key&lt;/code&gt; which is &lt;code&gt;RootUser&lt;/code&gt;, and &lt;code&gt;RootPass&lt;/code&gt;. And let's paste to the .env file&lt;br&gt;
&lt;/p&gt;

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

AWS_ACCESS_KEY_ID=myminioadmin
AWS_SECRET_ACCESS_KEY=minio-secret-key-change-me
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=&amp;lt;name_bucket_desire&amp;gt;
AWS_ENDPOINT=http://127.0.0.1:9001
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can connect and interact with MinIO from Laravel Application&lt;/p&gt;

&lt;p&gt;Open browser with address: &lt;a href="http://127.0.0.1:9002" rel="noopener noreferrer"&gt;http://127.0.0.1:9002&lt;/a&gt;, bummmm MinIO UI appears excellently&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fyfy6vhmjx7y6e3rmw0vz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fyfy6vhmjx7y6e3rmw0vz.png" alt="Image description" width="800" height="424"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Setup by using Docker
the docker-compose.yml will look like
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: '3.8'
services:
  minio:
    image: quay.io/minio/minio:latest  # Or your preferred MinIO image
    container_name: minio
    ports:
      - "9001:9001"  # Expose the MinIO server port
      - "9002:9002"  # Expose the MinIO console port
    environment:
      MINIO_ACCESS_KEY: minioadmin  # Replace with your desired username
      MINIO_SECRET_KEY: minioadmin  # Replace with your desired password
      MINIO_DEFAULT_BUCKETS: "my-test-bucket" # Optional: create a default bucket
    volumes:
      - ./data:/data  # Persistent storage for MinIO data
    command: server /data --address ":9001" --console-address ":9002"  # Start MinIO server with console on port 9001
    restart: unless-stopped  # Restart policy for the container
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And all the rest is like the option#1 to connect and interact with MinIO&lt;/p&gt;

&lt;p&gt;Reference: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://laravel-news.com/minio-s3-compliant-storage" rel="noopener noreferrer"&gt;https://laravel-news.com/minio-s3-compliant-storage&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://min.io/docs/minio/macos/index.html" rel="noopener noreferrer"&gt;https://min.io/docs/minio/macos/index.html&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>laravel</category>
      <category>s3</category>
      <category>minio</category>
      <category>development</category>
    </item>
    <item>
      <title>Integration Question List</title>
      <dc:creator>Viktor Le</dc:creator>
      <pubDate>Wed, 14 May 2025 10:39:53 +0000</pubDate>
      <link>https://dev.to/viktorle1294/integration-question-list-4je6</link>
      <guid>https://dev.to/viktorle1294/integration-question-list-4je6</guid>
      <description>&lt;p&gt;When we come into integrating your system with third party? What is question list to be asked?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;What is the primary purpose of the integration?&lt;/li&gt;
&lt;li&gt;Cost and How a request being charged?&lt;/li&gt;
&lt;li&gt;How to handle errors and exceptions or the service is unavailable?&lt;/li&gt;
&lt;li&gt;Testing and Deployment?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What else can you think to contribute to the list?&lt;/p&gt;

</description>
      <category>softwaredevelopment</category>
      <category>integrations</category>
      <category>discuss</category>
    </item>
    <item>
      <title>How to review Code better with VS Code</title>
      <dc:creator>Viktor Le</dc:creator>
      <pubDate>Thu, 20 Mar 2025 07:40:37 +0000</pubDate>
      <link>https://dev.to/viktorle1294/how-to-review-code-better-with-vs-code-3jhh</link>
      <guid>https://dev.to/viktorle1294/how-to-review-code-better-with-vs-code-3jhh</guid>
      <description>&lt;p&gt;To review code in GitHub using VS Code, install the "GitHub Pull Requests and Issues" extension, sign in, and then navigate to the pull request in the VS Code activity bar to view changes, add comments, and manage the review process. &lt;br&gt;
Here's a more detailed breakdown:&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Install Git: Ensure you have Git installed and configured on your system.&lt;/li&gt;
&lt;li&gt;Create a GitHub Account: You'll need a GitHub account to access and review code.&lt;/li&gt;
&lt;li&gt;Open VS Code: Launch Visual Studio Code. &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Install the Extension
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Open the Extensions view in VS Code (Ctrl+Shift+X or Cmd+Shift+X).&lt;/li&gt;
&lt;li&gt;Search for "GitHub Pull Requests and Issues".&lt;/li&gt;
&lt;li&gt;Install th
e extension by the Microsoft organization. &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Sign in to GitHub
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Click on the GitHub icon in the activity bar (it should appear after installing the extension).&lt;/li&gt;
&lt;li&gt;Click "Sign in to GitHub".&lt;/li&gt;
&lt;li&gt;Follow the on-screen instructions to authenticate with your GitHub account. &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. Navigate to a Pull Request
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Go to the pull request you want to review in the VS Code activity bar.&lt;/li&gt;
&lt;li&gt;You 
can find pull requests under the "Pull Requests" section. &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. Review the Code
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;View Changed Files: The extension displays the changed files in the pull request.&lt;/li&gt;
&lt;li&gt;Add Comments: Click on the "+" icon next to a line of code to add a comment.&lt;/li&gt;
&lt;li&gt;Add a Review: You can add a general review comment to the pull request.&lt;/li&gt;
&lt;li&gt;Checkout the Branch: Use the extension to checkout the pull request branch directly from VS Code.&lt;/li&gt;
&lt;li&gt;Check GitHub Actions: View the status of GitHub Actions workflows related to th
e pull request. &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  6. Additional Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;GitHub Copilot Integration: Use GitHub Copilot for AI-powered code review suggestions. &lt;/li&gt;
&lt;li&gt;Customizable Queries: Configure the extension to filter and organize pull requests based on your needs. &lt;/li&gt;
&lt;li&gt;Issue Management: Manage and create issues from within VS Code. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;This video demonstrates how to review a pull request from Visual Studio Code&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fdmcwtji9rqbfdseu6p1t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fdmcwtji9rqbfdseu6p1t.png" alt="Image description" width="800" height="524"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Link: &lt;a href="https://www.youtube.com/watch?v=DSl-L6B_Qb4" rel="noopener noreferrer"&gt;https://www.youtube.com/watch?v=DSl-L6B_Qb4&lt;/a&gt;&lt;/p&gt;

</description>
      <category>code</category>
      <category>codereview</category>
      <category>productivity</category>
      <category>vscode</category>
    </item>
    <item>
      <title>Laravel Policies and Gates, when to use</title>
      <dc:creator>Viktor Le</dc:creator>
      <pubDate>Tue, 18 Mar 2025 06:40:20 +0000</pubDate>
      <link>https://dev.to/viktorle1294/laravel-policies-and-gates-when-to-use-3n1p</link>
      <guid>https://dev.to/viktorle1294/laravel-policies-and-gates-when-to-use-3n1p</guid>
      <description>&lt;p&gt;I have an use case like this - "&lt;em&gt;&lt;strong&gt;User has permission to export Transaction from Admin Dashboard, because he has Admin Role&lt;/strong&gt;&lt;/em&gt;". For this use case, I ask myself, "&lt;em&gt;&lt;strong&gt;What shoud I use Policy or Gate in Laravel to implement it?&lt;/strong&gt;&lt;/em&gt;". Boomb, I think Gate is fast and simple to implement it. However keep asking myself, &lt;em&gt;&lt;strong&gt;When should I use Policy, any context to have a strong decision tree here?&lt;/strong&gt;&lt;/em&gt; Searching in Official docs and over the Internet, it comes up for me with the summary.&lt;/p&gt;

&lt;h2&gt;
  
  
  Policies
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Best for Resource-Based Authorization: Policies are ideal when you need to authorize actions on a specific model or resource. They are typically used for CRUD operations on models.&lt;/li&gt;
&lt;li&gt;Automatic Resolution: Laravel can automatically resolve policies for models if you follow naming conventions and register them in the AuthServiceProvider.&lt;/li&gt;
&lt;li&gt;Organized and Scalable: Policies provide a structured way to organize authorization logic, especially when dealing with multiple actions on a model.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Gates
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Best for General Authorization: Gates are more suited for general authorization that is not tied to a specific model. They are often used for actions that apply to the entire application or multiple models.&lt;/li&gt;
&lt;li&gt;Simple and Flexible: Gates are simple to define and can be used for quick checks that don't
require the structure of a policy.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Recommendation for Your Scenario
&lt;/h2&gt;

&lt;p&gt;Given your scenario where a user with an Admin role and a specific permission (export) needs to export all transactions, a Gate might be more appropriate. This is because the action of exporting all transactions is not tied to a specific instance of a model but is a general action that applies to the entire application.&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>authorization</category>
    </item>
    <item>
      <title>The N+1 query problem in Laravel and how to solve it</title>
      <dc:creator>Viktor Le</dc:creator>
      <pubDate>Fri, 14 Mar 2025 08:59:14 +0000</pubDate>
      <link>https://dev.to/viktorle1294/the-n1-query-problem-in-laravel-and-how-to-solve-it-4312</link>
      <guid>https://dev.to/viktorle1294/the-n1-query-problem-in-laravel-and-how-to-solve-it-4312</guid>
      <description>&lt;p&gt;The N+1 query problem in Laravel (and other ORMs) occurs when an application makes inefficient database queries, leading to performance issues. This problem typically arises in scenarios where a query is executed for each item in a collection, resulting in a large number of queries being executed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's explain the N+1 problem
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Inital Query (N): You start with a query that retrieves a collection of items. For example, fetching all users from a database.&lt;/li&gt;
&lt;li&gt;Subsequent Queries (+1): For each item in the collection, an additional query is executed to fetch related data. For instance, if you want to retrieve each user's posts, a separate query is executed for each user to get their posts.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Code example:
&lt;/h3&gt;

&lt;p&gt;Consider the following example in Laravel:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$users = User::all(); // N query
foreach ($users as $user) {
   echo $user-&amp;gt;posts; // +1 query for each user
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, if there are 100 users, the code will execute 1 query to get all 100 users, then 100 additional queries to get the posts for each user, resulting in 101 queries.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Solve the N+1 Problem
&lt;/h2&gt;

&lt;p&gt;So, Laravel provides several ways to solve the N+1 problem:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Eager Loading&lt;/strong&gt;: Use eager loading to retrieve related data in a single query. This is done using the with method.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$users = User::with('posts')-&amp;gt;get(); // N query
foreach ($users as $user) {
   echo $user-&amp;gt;posts; // No additional query for each user
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this improvement, Laravel will execute only two queries: one to get all users, and another to get all posts for those users.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Lazy Eager Loading&lt;/strong&gt;: If you need to load relationships after the initial query, you can use lazy eager loading with the load method.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$users = User::all();
$users-&amp;gt;load('posts');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Query Optimization&lt;/strong&gt;: Sometimes, restructuring your queries or using database indexes can help improve performance.
By using eager loading and other optimization teachniques, you can significantly reduce the number of queries executed and improve the performance of your system.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>laravel</category>
      <category>programming</category>
      <category>performance</category>
      <category>database</category>
    </item>
    <item>
      <title>Have you ever wondered when to use $this-&gt;app-&gt;environment() and app()-&gt;environment() in Laravel?</title>
      <dc:creator>Viktor Le</dc:creator>
      <pubDate>Tue, 11 Mar 2025 06:54:30 +0000</pubDate>
      <link>https://dev.to/viktorle1294/have-you-ever-wondered-when-to-use-this-app-environment-and-app-environment-in-laravel-3mg3</link>
      <guid>https://dev.to/viktorle1294/have-you-ever-wondered-when-to-use-this-app-environment-and-app-environment-in-laravel-3mg3</guid>
      <description>&lt;p&gt;Here I would like to show you when to use it properly and be headless. Just remember. Hope it could make your decisions stronger.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fg30prtb99gh57ir5mccs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fg30prtb99gh57ir5mccs.png" alt="Image description" width="800" height="275"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>codereview</category>
    </item>
    <item>
      <title>Boost fast your development with Laravel Market</title>
      <dc:creator>Viktor Le</dc:creator>
      <pubDate>Mon, 10 Mar 2025 10:51:25 +0000</pubDate>
      <link>https://dev.to/viktorle1294/boost-fast-your-development-with-laravel-market-49pc</link>
      <guid>https://dev.to/viktorle1294/boost-fast-your-development-with-laravel-market-49pc</guid>
      <description>&lt;p&gt;Boost fast Product Launching for a back-office website with Laravel market&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Laravel Nova &lt;a href="https://nova.laravel.com/docs/v5" rel="noopener noreferrer"&gt;https://nova.laravel.com/docs/v5&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Laravel Activity Log &lt;a href="https://spatie.be/docs/laravel-activitylog/v4/" rel="noopener noreferrer"&gt;https://spatie.be/docs/laravel-activitylog/v4/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Laravel Permission &lt;a href="https://spatie.be/docs/laravel-permission/v6/" rel="noopener noreferrer"&gt;https://spatie.be/docs/laravel-permission/v6/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Laravel Ticket &lt;a href="https://coderflex.com/open-source/docs" rel="noopener noreferrer"&gt;https://coderflex.com/open-source/docs&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The combination of these packages is completely game-changing in the product builder.&lt;/p&gt;

&lt;p&gt;💁 Don't forget to say BIG THANKS TO AI ( ChatGPT and Cursor)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fw8ejkhg5heusyd1ydv16.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fw8ejkhg5heusyd1ydv16.png" alt="Image description" width="800" height="832"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>programming</category>
      <category>productivity</category>
      <category>product</category>
    </item>
    <item>
      <title>How to review all git changes in a file</title>
      <dc:creator>Viktor Le</dc:creator>
      <pubDate>Thu, 20 Feb 2025 23:15:51 +0000</pubDate>
      <link>https://dev.to/viktorle1294/how-to-review-all-git-changes-in-a-file-58i4</link>
      <guid>https://dev.to/viktorle1294/how-to-review-all-git-changes-in-a-file-58i4</guid>
      <description>&lt;p&gt;Have you ever come into a situation that a production issue happened in the last two months but it was automatically fixed after that? Then, you brainstorm that it might a good side-effect change in a file which fixed that issue inadvertently.&lt;/p&gt;

&lt;p&gt;To investigate the issue with a hard-work you need a tool like viewing all changes in the last two months. And in this post, I will show you two handy tools:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Git command will list all commits for a file:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git log --oneline --follow -- the-path-to-the-file
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example, you have a file, named: &lt;code&gt;foo.js&lt;/code&gt; in a &lt;code&gt;src/app&lt;/code&gt; folder. The command you should type is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git log --oneline --follow -- src/app/foo.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's a handy little command for those times where you want to see all the Git commit ids associated with a file.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Gitk command&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A website needs a browser, and a file also needs Gitk to view too. You can read more in &lt;a href="https://git-scm.com/docs/gitk" rel="noopener noreferrer"&gt;git&lt;/a&gt; docs&lt;/p&gt;

&lt;p&gt;In Mac, if you do not still have it, then run &lt;code&gt;brew install git-gui&lt;/code&gt; to install it. You can read &lt;a href="https://stackoverflow.com/questions/30195143/gitk-command-not-found" rel="noopener noreferrer"&gt;this StackOverflow post&lt;/a&gt; in case you have trouble during the installation.&lt;/p&gt;

&lt;p&gt;So, to view the changes in a foo.js visually, just run the below command:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



</description>
      <category>git</category>
      <category>svc</category>
      <category>coding</category>
      <category>investigation</category>
    </item>
    <item>
      <title>How to visualize bar chart with react-chart-2, showing label on the bar</title>
      <dc:creator>Viktor Le</dc:creator>
      <pubDate>Thu, 28 Nov 2024 14:24:31 +0000</pubDate>
      <link>https://dev.to/viktorle1294/how-to-visualize-bar-chart-with-react-chart-2-with-having-label-showing-on-the-bar-21kb</link>
      <guid>https://dev.to/viktorle1294/how-to-visualize-bar-chart-with-react-chart-2-with-having-label-showing-on-the-bar-21kb</guid>
      <description>&lt;p&gt;To create a bar chart in React using react-chartjs-2 and display labels directly on the bars (not in the tooltip), you can use the react-chartjs-2 library combined with the Chart.js DataLabels plugin.&lt;/p&gt;

&lt;p&gt;Steps to Implement&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install the Required Libraries: Ensure you have both react-chartjs-2 and chart.js installed in your project. Additionally, install the chartjs-plugin-datalabels plugin:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install react-chartjs-2 chart.js chartjs-plugin-datalabels
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Import the Necessary Components: Import the chart component, plugin, and register them with Chart.js.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Set Up the Chart Configuration: Configure the options object to include the datalabels plugin.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ender the Chart: Use the Bar component from react-chartjs-2 to render your chart.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Example Code
&lt;/h2&gt;

&lt;p&gt;Here’s an example to create a bar chart with labels shown directly on the bars:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React from "react";
import { Bar } from "react-chartjs-2";
import {
  Chart as ChartJS,
  CategoryScale,
  LinearScale,
  BarElement,
  Title,
  Tooltip,
  Legend,
} from "chart.js";
import ChartDataLabels from "chartjs-plugin-datalabels";

// Register Chart.js components and plugins
ChartJS.register(
  CategoryScale,
  LinearScale,
  BarElement,
  Title,
  Tooltip,
  Legend,
  ChartDataLabels // Register the DataLabels plugin
);

const BarChartWithLabels = () =&amp;gt; {
  // Chart data
  const data = {
    labels: ["January", "February", "March", "April", "May"],
    datasets: [
      {
        label: "Sales",
        data: [30, 20, 50, 40, 60],
        backgroundColor: "rgba(75, 192, 192, 0.6)",
        borderColor: "rgba(75, 192, 192, 1)",
        borderWidth: 1,
      },
    ],
  };

  // Chart options
  const options = {
    responsive: true,
    plugins: {
      legend: {
        display: true,
        position: "top",
      },
      datalabels: {
        color: "black", // Label color
        anchor: "end", // Position the label near the bar's edge
        align: "top", // Align the label to the top of the bar
        formatter: (value) =&amp;gt; value, // Format the label (e.g., show the value)
      },
    },
    scales: {
      y: {
        beginAtZero: true,
      },
    },
  };

  return (
    &amp;lt;div style={{ width: "600px", margin: "0 auto" }}&amp;gt;
      &amp;lt;Bar data={data} options={options} /&amp;gt;
    &amp;lt;/div&amp;gt;
  );
};

export default BarChartWithLabels;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;QA for you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How to customize datalabels for each dataset when using stacked bar ?&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>programming</category>
      <category>javascript</category>
      <category>react</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
