<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>How to guide, Learn tips and tricks about programming with an example</title>
	<atom:link href="https://atcodex.com/how-to/feed/" rel="self" type="application/rss+xml" />
	<link>https://atcodex.com/how-to/</link>
	<description>Achieve financial success without sacrificing well-being! AtCodex provides actionable strategies for managing money, time, and personal growth—all in one place.</description>
	<lastBuildDate>Sun, 10 Oct 2021 08:04:05 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://atcodex.com/wp-content/uploads/2020/05/cropped-New-Project-1-32x32.png</url>
	<title>How to guide, Learn tips and tricks about programming with an example</title>
	<link>https://atcodex.com/how-to/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Check Atleast One Checkbox is Checked or Not in JQuery?</title>
		<link>https://atcodex.com/how-to/how-to-check-atleast-one-checkbox-is-checked-or-not-in-jquery/</link>
		
		<dc:creator><![CDATA[atcodex]]></dc:creator>
		<pubDate>Thu, 07 Oct 2021 08:02:15 +0000</pubDate>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[jQuery]]></category>
		<guid isPermaLink="false">https://atcodex.com/?p=1530</guid>

					<description><![CDATA[<p>In this tutorial, we will show you how to check at least one checkbox is checked or not in jquery. We have tried to explain this simple step by step. &#8230; </p>
<p>The post <a href="https://atcodex.com/how-to/how-to-check-atleast-one-checkbox-is-checked-or-not-in-jquery/">How to Check Atleast One Checkbox is Checked or Not in JQuery?</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In this tutorial, we will show you how to check at least one checkbox is checked or not in <a href="https://jquery.com/" target="_blank" rel="noreferrer noopener">jquery</a>.  We have tried to explain this simple step by step. you can see jquery for least one checkbox checked. </p>



<p>we have used a <strong>form selector</strong> to target the form and a function will execute whenever someone tries to submit the form. This function will check if at least one check box is checked or not.</p>



<p>we have used if the condition inside this function if at least one input type checkbox is check, the condition will output true. For this purpose input:checkbox selector is used to selecting all the checkboxes to check which checkbox is checked.</p>



<p></p>



<p>let&#8217;s see bellow example:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;!DOCTYPE html>
&lt;html>
&lt;head>
    &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js">&lt;/script>
&lt;/head>
&lt;body>
  
&lt;div>
    &lt;h1>How to check atleast one checkbox is checked or not in JQuery&lt;/h1>
    &lt;strong>Colors:&lt;/strong>
  
    &lt;input type="checkbox" value="true" class="color-check" name="colors[]"> Red
    &lt;input type="checkbox" value="true" class="color-check" name="colors[]"> Blue
    &lt;input type="checkbox" value="true" class="color-check" name="colors[]"> Black
    &lt;input type="checkbox" value="true" class="color-check" name="colors[]"> Orange
  
    &lt;button class="submit">Submit&lt;/button>
&lt;/div>
  
&lt;script type="text/javascript">
    $(".submit").click(function(){
         if($('.color-check').filter(':checked').length &lt; 1){
                alert("Please Check at least one Color Box");
                 return false;
         }else{
             alert("Proceed");
         }
    });
&lt;/script>
  
&lt;/body>
&lt;/html></pre>



<p>Hope you liked it.</p>



<h2 class="wp-block-heading">Recommended Posts For You</h2>



<ul class="wp-block-list"><li><a href="https://atcodex.com/php/remove-multiple-elements-from-an-array-in-javascript-jquery/" target="_blank" rel="noreferrer noopener">Remove multiple elements from an array in Javascript/jQuery</a></li><li><a href="https://atcodex.com/how-to/select-box-with-search-option-in-jquery-with-example/" target="_blank" rel="noreferrer noopener">Select box with search option in Jquery with example</a></li><li><a href="https://atcodex.com/how-to/how-to-enable-and-disable-the-submit-button-using-jquery/" target="_blank" rel="noreferrer noopener">How to enable and disable the submit button using jQuery?</a></li></ul>
<p>The post <a href="https://atcodex.com/how-to/how-to-check-atleast-one-checkbox-is-checked-or-not-in-jquery/">How to Check Atleast One Checkbox is Checked or Not in JQuery?</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Laravel create custom middleware for 301 redirections to non index.php url</title>
		<link>https://atcodex.com/how-to/laravel-create-custom-middleware-for-301-redirections-to-non-index-php-url/</link>
		
		<dc:creator><![CDATA[atcodex]]></dc:creator>
		<pubDate>Wed, 06 Oct 2021 03:01:27 +0000</pubDate>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Laravel]]></category>
		<guid isPermaLink="false">https://atcodex.com/?p=1528</guid>

					<description><![CDATA[<p>In today&#8217;s tutorial, we will learn how to create custom middleware for 301 redirections to non index.php URL. Having&#160;index.php&#160;in the URL is not good for the SEO practice. We can &#8230; </p>
<p>The post <a href="https://atcodex.com/how-to/laravel-create-custom-middleware-for-301-redirections-to-non-index-php-url/">Laravel create custom middleware for 301 redirections to non index.php url</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In today&#8217;s tutorial, we will learn how to create custom middleware for 301 redirections to non index.php URL.</p>



<p>Having&nbsp;<code>index.php</code>&nbsp;in the URL is not good for the SEO practice.</p>



<p>We can use .htaccess file to remove the index.php from the URL, which is also a very easy integration. But today we will only explain this via <a href="https://laravel.com/" target="_blank" rel="noreferrer noopener">Laravel </a>and creating middleware and defining login in it. </p>



<p><strong>Configure &#8220;RemoveIndexPhp&#8221; custom middleware</strong></p>



<p>In this step, let&#8217;s run the PHP artisan command to create middleware in which we will define the logic to remove the index.php.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">php artisan make:middleware RemoveIndexPhp
</pre>



<p><em></em></p>



<p>After running the above command, you will have a middleware file in the following directory&nbsp;<strong>app/Http/Middleware/</strong>. </p>



<p>Now open the &#8220;RemoveIndexPhp.php&#8221; file and update that with the below code :</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;?php

namespace App\Http\Middleware;

use Closure;

class RemoveIndexPhp
{

    public function handle($request, Closure $next)
    {
        $searchFor = "index.php";
        $strPosition = strpos($request->fullUrl(), $searchFor);
        if ($strPosition !== false) {
            $url = substr($request->fullUrl(), $strPosition + strlen($searchFor));
            return redirect(config('app.url') . $url, 301);
        }
        return $next($request);
    }
}</pre>



<p>Now register this middleware as routeMiddleware in the&nbsp;Kernel.php&nbsp;file. It&#8217;s mandatory when we create a middleware then we need to get it registered in the Kernel file.</p>



<p><strong>app/Http/Kernel.php</strong>&nbsp;:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">protected $routeMiddleware = [
        ....
        'RemoveIndexPhp' => \App\Http\Middleware\RemoveIndexPhp::class,
    ];
</pre>



<p><strong>Add route</strong></p>



<p>To test this example, I need to add a single route inside the group middleware :</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Route::group(array('middleware' => ['RemoveIndexPhp']), function ()
{
    Route::get('/',function(){
        return "Welcome to www.atcodex.com";
    });
});</pre>



<h2 class="wp-block-heading">Recommended Posts For You</h2>



<ul class="wp-block-list"><li><a href="https://atcodex.com/cpanel/how-to-set-up-redirects-in-cpanel/" target="_blank" rel="noreferrer noopener">How to Set Up Redirects in cPanel</a></li></ul>
<p>The post <a href="https://atcodex.com/how-to/laravel-create-custom-middleware-for-301-redirections-to-non-index-php-url/">Laravel create custom middleware for 301 redirections to non index.php url</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Laravel middleware to remove/trim empty whitespace from the input request</title>
		<link>https://atcodex.com/how-to/laravel-middleware-to-remove-trim-empty-whitespace-from-the-input-request/</link>
		
		<dc:creator><![CDATA[atcodex]]></dc:creator>
		<pubDate>Tue, 05 Oct 2021 02:03:47 +0000</pubDate>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Laravel]]></category>
		<guid isPermaLink="false">https://atcodex.com/?p=1524</guid>

					<description><![CDATA[<p>In this Laravel PHP Tutorial, we will let you know how to create custom middleware to remove/delete whitespace from the string in the request. Laravel is a great framework that &#8230; </p>
<p>The post <a href="https://atcodex.com/how-to/laravel-middleware-to-remove-trim-empty-whitespace-from-the-input-request/">Laravel middleware to remove/trim empty whitespace from the input request</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In this Laravel <a href="https://www.php.net/" target="_blank" rel="noreferrer noopener">PHP </a>Tutorial, we will let you know how to create custom middleware to remove/delete whitespace from the string in the request.</p>



<p>Laravel is a great framework that provides a variety of tools and inbuilt functions to tackle almost everything we need to create a good web application. </p>



<p>Whitespace is any string of text composed only of spaces, tabs,<strong> or line breaks</strong>. These characters allow you to format your code in a way that will make it easily readable by yourself and other people. But in programming when we are working array then whitespace can affect your code logic, so it&#8217;s always a good idea to trim the whitespace from the incoming request. Because users can&#8217;t be trusted in the programming so we need to protect our code as much as possible.</p>



<p></p>



<p>Sometimes user searches for empty strings and gets empty results because empty strings behave like characters which are accurate but this is not the good practice to send user input data directly into the query without sanitizing input data. So we always recommend sanitizing the data before processing in the logic.</p>



<p>You can trim all input using the custom middleware in Laravel. So let&#8217;s make a custom middleware for removing and trimming blank or white space from the input string.</p>



<h2 class="wp-block-heading"><strong>Create Middleware</strong></h2>



<p>You can use the PHP artisan command to create the middleware file to trim request data.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">php artisan make:middleware BeforeAutoTrimmer
</pre>



<p>Update the below code in the newly created middleware file <strong>(located at app/Http/Middleware/BeforeAutoTrimmer.php)</strong>.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;?php 
namespace App\Http\Middleware;
use Closure;

class BeforeAutoTrimmer {
    
    public function handle($request, Closure $next)
    {
        $request->merge(array_map('trim', $request->all()));
        return $next($request);
    }
}</pre>



<h2 class="wp-block-heading"><strong>Update the Laravel Kernel file</strong></h2>



<p>Once you have done with your middleware file, you need to tell the Laravel application to run middleware on each request or you can apply it for a specific group to trim whitespace from the request data.</p>



<p><strong>app/Http/Kernel.php</strong>:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">protected $middleware = [
        // ..
        \App\Http\Middleware\BeforeAutoTrimmer::class,
    ];</pre>



<h2 class="wp-block-heading">Recommended Posts For You</h2>



<ul class="wp-block-list"><li><a href="https://atcodex.com/php/how-to-remove-last-character-from-string-in-php/" target="_blank" rel="noreferrer noopener">How to Remove Last Character from String in PHP</a></li><li><a href="https://atcodex.com/php/how-to-find-the-length-of-a-string-in-php/" target="_blank" rel="noreferrer noopener">How to find the length of a string in PHP</a></li></ul>



<p></p>
<p>The post <a href="https://atcodex.com/how-to/laravel-middleware-to-remove-trim-empty-whitespace-from-the-input-request/">Laravel middleware to remove/trim empty whitespace from the input request</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to validate custom Date Format with Laravel validator</title>
		<link>https://atcodex.com/how-to/how-to-validate-custom-date-format-with-laravel-validator/</link>
		
		<dc:creator><![CDATA[atcodex]]></dc:creator>
		<pubDate>Mon, 04 Oct 2021 00:41:22 +0000</pubDate>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Laravel]]></category>
		<guid isPermaLink="false">https://atcodex.com/?p=1520</guid>

					<description><![CDATA[<p>In this Laravel PHP Tutorial, We will learn how to validate custom date format with laravel validator. Laravel has provided many features and with its updates for data validation. You &#8230; </p>
<p>The post <a href="https://atcodex.com/how-to/how-to-validate-custom-date-format-with-laravel-validator/">How to validate custom Date Format with Laravel validator</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In this <a href="https://laravel.com/" target="_blank" rel="noreferrer noopener">Laravel </a>PHP Tutorial, We will learn how to validate custom date format with laravel validator. </p>



<p>Laravel has provided many features and with its updates for data validation. You can validate the incoming request the way you want using middleware and if also using some inbuilt function. In today&#8217;s tutorial, we will learn how to validate only the date format.</p>



<p>You can validate date after, date_format, after_or_equal:date, before:date, before_or_equal:date etc. Laravel date validation rules support all formats supported by PHP&#8217;s Date class.</p>



<p>In this example, you will see the use of the following different date validation rules that are provided by Laravel. Some of them I have mentioned below, You will see examples for each which will help you to understand the use of date validation easily in laravel.</p>



<ul class="wp-block-list"><li>date</li><li>date_format</li><li>after:date</li><li>after_or_equal:date</li><li>before:date</li><li>before_or_equal:date</li></ul>



<h2 class="wp-block-heading"><strong>Date Validation</strong></h2>



<p>This is the simple validation and you can validate the incoming request value by simply putting the input. value in the array with a date.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">public function save(Request $request)
{
   
    $request->validate([        
        'date_of_birth' => 'date'
    ]);
  
}</pre>



<h2 class="wp-block-heading"><strong>Date Validation for date_format</strong></h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">
public function save(Request $request)
{
   
    $request->validate([        
        'date_of_birth' => 'date_format:m/d/Y'
    ]);
  
}</pre>



<h2 class="wp-block-heading"><strong>Date Validation for after</strong></h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">public function save(Request $request)
{
   
    $request->validate([        
        'start_date' => 'date_format:m/d/Y|after:tomorrow'
    ]);
  
}</pre>



<h2 class="wp-block-heading"><strong>Date Validation for after_or_equal</strong></h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">public function save(Request $request)
{
   $now=date('m/d/Y');
    $request->validate([        
        'start_date' => 'date_format:m/d/Y|after_or_equal:'.$now
    ]);
  
}</pre>



<h2 class="wp-block-heading"><strong>Date Validation for before</strong></h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">public function save(Request $request)
{
   
    $request->validate([        
        'end_date' => 'date_format:m/d/Y|before:start_date',
        'start_date' => 'date_format:m/d/Y|after:tomorrow'
    ]);
  
}</pre>



<h2 class="wp-block-heading"><strong>Date Validation for before_or_equal</strong></h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">public function save(Request $request)
{
   
    $request->validate([        
        'end_date' => 'date_format:m/d/Y|before_or_equal:start_date',
        'start_date' => 'date_format:m/d/Y|after:tomorrow'
    ]);
  
}</pre>



<p>Sometimes we develop an application having start and end date functionality for any reservation and in this case, there should be validation like the end date must be after the start date. This is a very useful and easy-to-use validation that can be easily used in travel or hotel kinds of websites.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">public function save(Request $request)
{
   
    $request->validate([       
        'start_date' => 'date_format:m/d/Y',
        'end_date' => 'date_format:m/d/Y|after:start_date'
    ]);
   
}</pre>



<h2 class="wp-block-heading">Recommended Posts For You</h2>



<ul class="wp-block-list"><li><a href="https://atcodex.com/php/how-to-get-number-of-days-between-two-dates-in-php/" target="_blank" rel="noreferrer noopener">How to Get Number of Days Between Two Dates in PHP</a></li><li><a href="https://atcodex.com/php/php-date-and-time-formats/" target="_blank" rel="noreferrer noopener">PHP Date and Time formats</a></li></ul>



<p></p>
<p>The post <a href="https://atcodex.com/how-to/how-to-validate-custom-date-format-with-laravel-validator/">How to validate custom Date Format with Laravel validator</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Laravel 8 &#8211; How to move files from one folder to another folder</title>
		<link>https://atcodex.com/how-to/laravel-8-how-to-move-files-from-one-folder-to-another-folder/</link>
		
		<dc:creator><![CDATA[atcodex]]></dc:creator>
		<pubDate>Sat, 02 Oct 2021 10:02:27 +0000</pubDate>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Laravel]]></category>
		<guid isPermaLink="false">https://atcodex.com/?p=1504</guid>

					<description><![CDATA[<p>In this Laravel tutorial, we will learn how we can move files from one folder to another folder or from one location to another location with a simple example. When &#8230; </p>
<p>The post <a href="https://atcodex.com/how-to/laravel-8-how-to-move-files-from-one-folder-to-another-folder/">Laravel 8 &#8211; How to move files from one folder to another folder</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In this <a href="https://laravel.com/" target="_blank" rel="noreferrer noopener">Laravel </a>tutorial, we will learn how we can move files from one folder to another folder or from one location to another location with a simple example.</p>



<p>When we have to move files from one location to another in our system then it is very is by just copying the file from one location to another and paste it to desired location or folder. The content will move to that particular destination. </p>



<p>But what if we are required to perform the same thing using coding and that too online.</p>



<p>Let&#8217;s suppose we have a repository kind of website where users can create the folders and store the content in them. And again if the user wants, he/she can move that folder file to a different folder. So today we will learn how we can perform the same thing with the help of Laravel. </p>



<p>If you are familiar with Linux then there is also a command&nbsp;<code>mv</code>&nbsp;to move the file that needs source and destination. Linux gives us powerful options to take care of all these things easily. But if we have to perform the same thing using coding and then it becomes a little bit tedious. In Laravel, we can achieve it by using&nbsp;<code>move</code>&nbsp;method with&nbsp;<code>File</code>&nbsp;or&nbsp;<code>Storage</code>&nbsp;Facade.</p>



<h2 class="wp-block-heading"><strong>Move file using File Facade</strong></h2>



<p>You can use the below line of code to move files from one path to another, you just need to replace the from_path and to_path with their actual path</p>



<pre class="wp-block-code"><code>File::move(from_path, to_path);
</code></pre>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;?php
  
namespace App\Http\Controllers;
  
use Illuminate\Http\Request;
use File;
  
class DemoController extends Controller
{
    /**
     * Write code on Construct
     *
     * @return \Illuminate\Http\Response
     */  
    public function moveImage(Request $request)
    {
        File::move(public_path('exist/test.png'), public_path('move/test_move.png'));
   
    
    }
}</pre>



<h2 class="wp-block-heading"><strong>Move file using Storage Facade</strong></h2>



<p>You can also use Storage Facade to move files:</p>



<pre class="wp-block-code"><code>Storage::move(from_path, to_path);
</code></pre>



<p>Let&#8217;s suppose you want to move the file &#8216;file1.jpg&#8217; from the old directory to the new directory then you can use the below line of code</p>



<pre class="wp-block-code"><code>Storage::move('old/file.jpg', 'new/file.jpg');
</code></pre>



<h2 class="wp-block-heading">Example</h2>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;?php
  
namespace App\Http\Controllers;
  
use Illuminate\Http\Request;
use Storage;
  
class DemoController extends Controller
{
    /**
     * Write code on Construct
     *
     * @return \Illuminate\Http\Response
     */  
    public function moveImage(Request $request)
    {
        Storage::move('exist/test.png', 'move/test_move.png');
   
      
    }
}</pre>



<h2 class="wp-block-heading">Recommended Posts For You</h2>



<ul class="wp-block-list"><li><a href="https://atcodex.com/how-to/laravel-8-how-to-copy-files-from-one-folder-to-another-folder/" target="_blank" rel="noreferrer noopener">Laravel 8 – How to copy files from one folder to another folder</a></li><li><a href="https://atcodex.com/php/how-to-rename-copy-and-delete-file-name-in-php/" target="_blank" rel="noreferrer noopener">How to Rename, Copy, and Delete File in PHP</a></li></ul>
<p>The post <a href="https://atcodex.com/how-to/laravel-8-how-to-move-files-from-one-folder-to-another-folder/">Laravel 8 &#8211; How to move files from one folder to another folder</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Laravel 8 &#8211; How to copy files from one folder to another folder</title>
		<link>https://atcodex.com/how-to/laravel-8-how-to-copy-files-from-one-folder-to-another-folder/</link>
		
		<dc:creator><![CDATA[atcodex]]></dc:creator>
		<pubDate>Fri, 01 Oct 2021 02:44:24 +0000</pubDate>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Laravel]]></category>
		<guid isPermaLink="false">https://atcodex.com/?p=1501</guid>

					<description><![CDATA[<p>In this Laravel tutorial, we will learn how we can copy files from one folder to another folder. file copy required many times when working on the project which is &#8230; </p>
<p>The post <a href="https://atcodex.com/how-to/laravel-8-how-to-copy-files-from-one-folder-to-another-folder/">Laravel 8 &#8211; How to copy files from one folder to another folder</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In this Laravel tutorial, we will learn how we can copy files from one folder to another folder. </p>



<p>file copy required many times when working on the project which is a very common activity and one should be aware of it that how we can do it.</p>



<p>Sometimes we need to copy the files from one location to another in the project. In Linux we have done so many times but what if it is required to do with <a href="https://laravel.com/" target="_blank" rel="noreferrer noopener">Laravel</a>. So today we are going to make you understand, how you can copy the file from one location to another location using laravel.</p>



<p>And If you are familiar with Linux then there is a command&nbsp;<code>cp</code>&nbsp;to copy files from one location to another. In Laravel, we can achieve it by using&nbsp;<code>copy</code>&nbsp;method with&nbsp;<code>File</code>&nbsp;or&nbsp;<code>Storage</code>&nbsp;Facade.</p>



<h2 class="wp-block-heading">Copy file using File Facade</h2>



<p>You can simply use the below syntax to copy files from one path to another, you just need to replace the from_path and to_path with their actual path</p>



<pre class="wp-block-code"><code>File::copy(from_path, to_path);
</code></pre>



<h2 class="wp-block-heading"><strong>Copy file using Storage Facade</strong></h2>



<p>We can copy files from one location to another using <a href="https://laravel.com/docs/8.x/filesystem" target="_blank" rel="noreferrer noopener">Storage Facade </a>also. Below is the code for the same.</p>



<pre class="wp-block-code"><code>Storage::copy(from_path, to_path);
</code></pre>



<p>Let&#8217;s suppose you want to copy the file &#8216;file1.jpg&#8217; from the old directory to the new directory then you can use the below line of code</p>



<pre class="wp-block-code"><code>Storage::copy('old/file.jpg', 'new/file.jpg');
</code></pre>



<p>Hope the above article helps you in solving your query.</p>



<h2 class="wp-block-heading">Recommended Posts For You</h2>



<ul class="wp-block-list"><li><a href="https://atcodex.com/php/how-to-rename-copy-and-delete-file-name-in-php/" target="_blank" rel="noreferrer noopener">How to Rename, Copy, and Delete File in PHP</a></li><li><a href="https://atcodex.com/how-to/laravel-8-how-to-move-files-from-one-folder-to-another-folder/" target="_blank" rel="noreferrer noopener">Laravel 8 – How to move files from one folder to another folder</a></li></ul>
<p>The post <a href="https://atcodex.com/how-to/laravel-8-how-to-copy-files-from-one-folder-to-another-folder/">Laravel 8 &#8211; How to copy files from one folder to another folder</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to Capture Screenshot of a Website Using PHP</title>
		<link>https://atcodex.com/how-to/how-to-capture-screenshot-of-a-website-using-php/</link>
		
		<dc:creator><![CDATA[atcodex]]></dc:creator>
		<pubDate>Thu, 30 Sep 2021 06:28:17 +0000</pubDate>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[PHP]]></category>
		<guid isPermaLink="false">https://atcodex.com/?p=1493</guid>

					<description><![CDATA[<p>Sometime we need to capture the screenshot of a website. In this tutorial we will learn how to capture screenshot of a website using php. We will user ScreenshotLayer to &#8230; </p>
<p>The post <a href="https://atcodex.com/how-to/how-to-capture-screenshot-of-a-website-using-php/">How to Capture Screenshot of a Website Using PHP</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Sometime we need to capture the screenshot of a website. In this tutorial we will learn how to capture screenshot of a website using php. We will user  ScreenshotLayer  to capture screenshot of a website. In this we will use PHP class  <strong>“screenshot.class.php”</strong>. It will send an web request to ScreenshotLayer API to grab the website screenshot in JPG, GIF or PNG formats. </p>



<h2 class="wp-block-heading"><strong>Get ScreenshotLayer API key:</strong></h2>



<p>Now you need the api key to access this class code. Using this api key an HTTP request send to screenshotLayer service to capture the screen. First you have to login to the website and choose the plan as per requirement. after login you will get an API key that you can use further to capture the screenshot of the website.</p>



<p><strong>To get api key SignUp here:</strong><a href="https://screenshotlayer.com/product" target="_blank" rel="noreferrer noopener"> <em>https://screenshotlayer.com/product</em></a></p>



<h2 class="wp-block-heading"><strong>Use ScreenShotLayer Php Class code:</strong></h2>



<p>In the below <strong>screenshot.class.php code</strong>, Just use you own API-KEY in this file and include this file in your screen capture <strong>sample.php</strong> file.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;?php 

class screenShot{ 
    
    //********************************************************* 
    // Settings 
    //********************************************************* 
    
    //Your screenshotLayer API key 
    //Available at https://screenshotlayer.com/product 
    private $apiKey = 'YOUR_API_KEY_HERE'; 
    
    //API endpoint 
    //only needs to change if the API changes location 
    private $endPoint = 'http://api.screenshotlayer.com/api/capture'; 
    
    //Secret Keyword defined in your screenshotLayer dashboard 
    //leave blank if you have not activated this feature 
    private $secretKey = ''; 
    
    //API key/value pair params 
    public $params = array(); 
    
    //response capture 
    public $capture; 
    
    //image info 
    public $imageInfo; 
    
    /* 
    method: class construction 
    usage: screenShot([string url]); 
    params: url = URL to web video 
    
    The screenshotLayer API requires a valid webpage URL to capture. 
    
    returns: null 
    */ 
    public function __construct($url='',$format='PNG'){ 
        
        $this->params['url'] = $url; 
        if( !empty($this->secretKey) ){ 
            
            $secret = md5($url.$this->secretKey); 
            $this->params['secret_key'] = $secret; 
            
        } 
        
    } 
    
    /* 
    method: displayImage 
    usage: displayImage(void); 
    params: none 
    
    This method will write an image tag with the correct request url. 
    Note: this method will not verify the request is to a valid url and 
    will return a broken image if not. 
    
    returns: null 
    */ 
    public function displayImage(){ 
        
        $request = $this->buildRequest(); 
        
        echo '&lt;img src="'.$request.'">'; 
        
    } 
    
    /* 
    method: captureScreen 
    usage: captureScreen(void); 
    params: none 
    
    This method will query the api for the binary code of the captured webpage. 
    
    returns: null 
    */ 
    public function capturePage(){ 
        
        $request = $this->buildRequest(); 
        
        $this->capture = file_get_contents($request); 
        
        $this->imageInfo = getimagesizefromstring($this->capture); 
        
        if( empty($this->imageInfo) ){ 
            
            if( empty($this->capture) ){ 
                
                throw new Exception('An unknown error has occured'); 
                
            }else{ 
                
                $response = json_decode($this->capture); 
                
                throw new Exception($response->error->info); 
                
            } 
            
        } 
        
    } 
    
    /* 
    method: downloadCapture 
    usage: downloadCapture([string fileName='']); 
    params: fileName = The name of the file written to disk 
    
    This method will download the captured image to the client. 
    
    returns: null 
    */ 
    public function downloadCapture($fileName=''){ 
        
        $fileName = ( empty($fileName) ) ? 'capture' : $fileName; 
        
        if( empty($this->capture) ){ 
            
            throw new Exception('No image has been captured'); 
            
        } 
        
        header('Content-Type: '.$this->imageInfo['mime']); 
        header('Content-Disposition: attachment; filename="'.$fileName.'"'); 
        header('Content-Transfer-Encoding: binary'); 
        
        echo $this->capture; 
        
    } 
    
    /* 
    method: displayCapture 
    usage: displayCapture(void); 
    params: none 
    
    This method will display the captured image to the browser. 
    
    returns: null 
    */ 
    public function displayCapture(){ 
        
        if( empty($this->capture) ){ 
            
            throw new Exception('No image has been captured'); 
            
        } 
        
        header('Content-Type: '.$this->imageInfo['mime']); 
        
        echo $this->capture; 
        
    } 
    
    /* 
    method: buildRequest 
    usage: buildRequest(void); 
    params: none 
    
    This method will build the api request url. 
    
    returns: api request url 
    */ 
    public function buildRequest(){ 
        
        if( empty($this->params['url']) ){ 
            
            throw new Exception('API requires URL to video'); 
            
        } 
        
        $request = $this->endPoint.'?access_key='.$this->apiKey; 
        
        foreach( $this->params as $key=>$value ){ 
            
            if( $key == 'url' ){ 
                
                $request .= '&amp;url='.urlencode($value); 
                
            }else{ 
                
                $request .= '&amp;'.$key.'='.$value; 
                
            } 
            
        } 
        
        return $request; 
        
    } 
    
    /* 
    method: setParam 
    usage: setParam(string key, string value); 
    params: key = key of the params key/value pair 
             value = value of the params key/value pair 
    
    add or change the params key/value pair specified. 
    
    returns: null 
    */ 
    public function setParam($key,$value){ 
        
        $this->params[$key] = $value; 
        
    } 
} 
?></pre>



<h2 class="wp-block-heading"><strong>Write PHP code to Capture Screen</strong></h2>



<p>After that use the below mentioend code to capture the screen. Follow below <strong>“sample.php”</strong> file code for this.  we can create an object of the screenshot class by passign the url of the website, which we want to capture. </p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;?php 

//include screenShot class 
include('screenshot.class.php'); 

//use own website url 

$screenShot = new screenShot('https://atcodex.com/'); 

//display html image tag for captured webpage 

$screenShot->displayImage(); 


//$screenShot->capturePage(); 

//$screenShot->downloadCapture('test.png'); 

//$screenShot->displayCapture(); 

?></pre>



<p></p>



<p>Run the code and you will the get screenshot of  the website. <strong>ScreenshotLayer </strong> stores your image for 30 days only untill you capture again.</p>



<p><strong>You can also check complete ScreenshotLayer API documentation here:</strong> <em>https://screenshotlayer.com/documentation</em>. </p>



<p>There are multple tools and library available out there to capture the screenshot of the website. But personally i like this very easy to integrate on any website. </p>



<h2 class="wp-block-heading">Recommended Posts For You</h2>



<p>You can also visit the following related posts </p>



<ul class="wp-block-list"><li><a href="https://atcodex.com/php/jquery-crop-and-resize-an-image-before-upload-using-php/" target="_blank" rel="noreferrer noopener">jQuery crop and resize an image before upload using PHP</a></li><li><a href="https://atcodex.com/how-to/compress-image-before-upload-using-php/" target="_blank" rel="noreferrer noopener">Compress Image Before Upload using PHP</a></li><li><a href="https://atcodex.com/php/saving-an-image-from-url-in-php/" target="_blank" rel="noreferrer noopener">Saving an Image from URL in PHP</a></li></ul>



<p></p>
<p>The post <a href="https://atcodex.com/how-to/how-to-capture-screenshot-of-a-website-using-php/">How to Capture Screenshot of a Website Using PHP</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to get the first character of a string in PHP</title>
		<link>https://atcodex.com/php/how-to-get-the-first-character-of-a-string-in-php/</link>
		
		<dc:creator><![CDATA[atcodex]]></dc:creator>
		<pubDate>Sat, 10 Oct 2020 14:15:53 +0000</pubDate>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[PHP]]></category>
		<guid isPermaLink="false">https://atcodex.com/?p=1166</guid>

					<description><![CDATA[<p>Many times in the application we required to add or remove some part of the string for use. So in this tutorial, we will learn how to get the first &#8230; </p>
<p>The post <a href="https://atcodex.com/php/how-to-get-the-first-character-of-a-string-in-php/">How to get the first character of a string in PHP</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Many times in the application we required to add or remove some part of the string for use. So in this tutorial, we will learn how to get the first characters of a string in PHP. For example, we have to take the first 5 characters from the string to show in the website, or we need to show string first character in the web application. In this scenario, we have to use substr() function which gives options to manipulate the string as per need. </p>



<p><strong>Syntax:</strong></p>



<pre class="wp-block-code"><code>substr(string,start,length)</code></pre>



<p>Let&#8217;s understand the <strong><a href="https://www.php.net/manual/en/function.substr.php" target="_blank" rel="noreferrer noopener">substr</a></strong>() function and see in how many ways we can get the characters from the string as per requirement.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">&lt;?php

echo substr("atcodex.com",10)."&lt;br>";
echo substr("atcodex.com",1)."&lt;br>";
echo substr("atcodex.com",3)."&lt;br>";
echo substr("atcodex.com",7)."&lt;br>";
echo "&lt;br>";

// Negative numbers:
echo substr("atcodex.com",-1)."&lt;br>";
echo substr("atcodex.com",-10)."&lt;br>";
echo substr("atcodex.com",-8)."&lt;br>";
echo substr("atcodex.com",-4)."&lt;br>";
echo "&lt;br>";

// using length
echo substr("atcodex.com",0,1)."&lt;br>";
echo substr("atcodex.com",1,4)."&lt;br>";
echo substr("atcodex.com",-3,1)."&lt;br>";
echo substr("atcodex.com",4,7)."&lt;br>";

?></pre>



<p><strong>Output</strong>:</p>



<pre class="wp-block-code"><code>m
tcodex.com
odex.com
.com

m
tcodex.com
odex.com
.com

a
tcod
c
dex.com</code></pre>



<p>In the above example, you can see, we have passed 3 parameters to the function. first is the string second is the start position and the third is the length. If we take the second value in positive the characters will be counted from the left and if we take the second value negative then the characters will be counted from the right end of the string. We have provided the different scenarios in the above example, test them by changing the value of second and third value in the function and manipulate the result.</p>



<h2 class="wp-block-heading">How to get the first character of string if we have special characters</h2>



<p><strong>substr() </strong>function work will with normal string, but when we have special characters in the string then it will not give correct output.</p>



<p><strong>substr() </strong>function is not able to read the special character from the string. So in that case PHP provides us the other function called <a href="https://atcodex.com/php/use-of-mb_substr-with-example/" target="_blank" rel="noreferrer noopener">mb_substr</a>() function, which has the almost the same functionality as substr() has, but the only difference is that mb_sbustr() can work with special character as it has the option to pass the encoding format in the function. </p>



<p>To get the first character of a string in PHP, you can use a built-in function i.e. <strong>substr</strong>(). But if you have special characters in the strings then it will show you a black symbol or some unreadable symbol rather than to show that special character as an output.&nbsp;</p>



<p><strong>NOTE:  mb_substr&nbsp;is used to get the character of a string that contains special characters:</strong></p>



<h2 class="wp-block-heading">Conclusion:</h2>



<p>We have tried to explain the possible scenario in which you can understand the different ways to manipulate the string using <strong>substr() </strong>function. Hope you liked the post. You can also check <a href="https://atcodex.com/php/how-to-remove-last-character-from-string-in-php/" target="_blank" rel="noreferrer noopener">How to Remove Last Character from String in PHP</a> in which have explained all the possible methods and ways to manipulate the string and how to get any part of the string using 4 different methods.</p>
<p>The post <a href="https://atcodex.com/php/how-to-get-the-first-character-of-a-string-in-php/">How to get the first character of a string in PHP</a> appeared first on <a href="https://atcodex.com">AtCodex: Empowering Your Financial Journey &amp; Personal Well-Being</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
