<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Syed Tahir Ali Jan on Medium]]></title>
        <description><![CDATA[Stories by Syed Tahir Ali Jan on Medium]]></description>
        <link>https://medium.com/@stahiralijan?source=rss-bb1da8b6bb14------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4KQSirs6W5AYvNk_pikowg.jpeg</url>
            <title>Stories by Syed Tahir Ali Jan on Medium</title>
            <link>https://medium.com/@stahiralijan?source=rss-bb1da8b6bb14------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 26 May 2026 10:08:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@stahiralijan/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Event-driven Development in Laravel]]></title>
            <link>https://medium.com/@stahiralijan/event-driven-development-in-laravel-6ed35c054445?source=rss-bb1da8b6bb14------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ed35c054445</guid>
            <dc:creator><![CDATA[Syed Tahir Ali Jan]]></dc:creator>
            <pubDate>Sun, 01 Oct 2023 13:09:31 GMT</pubDate>
            <atom:updated>2023-10-01T13:09:31.120Z</atom:updated>
            <content:encoded><![CDATA[<p>This article was originally published on <a href="https://tahirjan.com">tahirjan.com</a></p><p><a href="https://tahirjan.com/event-driven-development-in-laravel/">Event driven Development in Laravel</a></p><p>In the world of modern web development, creating interactive and responsive applications is key to providing a seamless user experience. Laravel, a popular PHP framework, offers a robust foundation for building such applications. One powerful concept that Laravel brings to the table is event-based development. In this article, we’ll explore how to harness the power of events in Laravel by creating a real-world example: ordering food from an online restaurant menu.</p><h3>What are Events in Laravel?</h3><p>Events in Laravel allow you to create and handle custom events within your application. These events can be triggered at specific points in your code and can be listened to by one or more event listeners. Event-based development follows the Publish-Subscribe pattern, where publishers emit events, and subscribers listen for and react to those events.</p><h3>Setting Up the Laravel Project</h3><p>Before we dive into the code, make sure you have Laravel installed on your system. If not, you can follow the installation instructions on the Laravel website.</p><p>Let’s start by creating a new Laravel project named “Restaurant.&quot;</p><pre>laravel new Restaurant</pre><p>Now, navigate to your project’s root folder and open it in your favorite code editor.</p><h3>Creating the Menu</h3><p>In our food ordering example, we’ll begin by creating a menu of delicious items. We’ll define these items as an array in our code.</p><pre>// routes/web.php<br><br>Route::get(&#39;/&#39;, function () {<br>    $menu = [<br>        &#39;Burger&#39; =&gt; 10,<br>        &#39;Pizza&#39; =&gt; 12,<br>        &#39;Pasta&#39; =&gt; 8,<br>        &#39;Salad&#39; =&gt; 6,<br>    ];<br><br>    return view(&#39;menu&#39;, [&#39;menu&#39; =&gt; $menu]);<br>});</pre><p>Here, we define a route that renders a view named “menu&quot; and passes an array of food items with their prices.</p><h3>Creating the Menu View</h3><p>Next, we’ll create a menu view that displays the available food items and allows users to place an order.</p><pre>&lt;!-- resources/views/menu.blade.php --&gt;<br><br>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;title&gt;Food Menu&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;h1&gt;Food Menu&lt;/h1&gt;<br>    &lt;ul&gt;<br>        @foreach($menu as $item =&gt; $price)<br>            &lt;li&gt;<br>                {{ $item }} - ${{ $price }}<br>                &lt;form method=&quot;POST&quot; action=&quot;{{ route(&#39;order&#39;, $item) }}&quot;&gt;<br>                    @csrf<br>                    &lt;button type=&quot;submit&quot;&gt;Order&lt;/button&gt;<br>                &lt;/form&gt;<br>            &lt;/li&gt;<br>        @endforeach<br>    &lt;/ul&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>In this view, we iterate over the menu items, display their names and prices, and provide an “Order” button for each item. The form associated with each item will submit a POST request to the “order” route with the item name as a parameter. I know this looks bad but bear with me for this simple example.</p><h3>Defining the Event</h3><p>Now, let’s define an event that represents an order being placed. We’ll call it “FoodOrderedEvent.&quot;</p><pre>php artisan make:event FoodOrderedEvent</pre><p>This command generates a new event class in the “app/Events&quot; directory. Open the &quot;FoodOrderedEvent.php&quot; file and add a public property to hold the ordered item.</p><pre>&lt;?php<br><br>// app/Events/FoodOrderedEvent.php<br><br>namespace App\Events;<br><br>use ...<br><br>class FoodOrderedEvent<br>{<br>    use Dispatchable, InteractsWithSockets, SerializesModels;<br><br>    public string $item;<br>  <br>    public function __construct(string $item)<br>    {<br>        $this-&gt;item = $item;<br>    }<br><br>    ...<br>}</pre><h3>Creating an Event Listener</h3><p>Next, we’ll create an event listener to handle the food orders. Run the following command to generate an event listener.</p><pre>php artisan make:listener OrderListener</pre><p>Open the “OrderListener.php&quot; file in the &quot;app/Listeners&quot; directory. In the &quot;handle&quot; method, we&#39;ll simulate processing the order by logging a message.</p><pre>&lt;?php<br><br>// app/Listeners/OrderListener.php<br><br>namespace App\Listeners;<br><br>use App\Events\FoodOrderedEvent;<br>use Illuminate\Contracts\Queue\ShouldQueue;<br>use Illuminate\Queue\InteractsWithQueue;<br><br>class OrderListener<br>{<br>     public function handle(FoodOrderedEvent $event)<br>     {<br>         $item = $event-&gt;item;<br>         Log::info(&quot;Order placed for $item.&quot;);<br>     }<br>}</pre><h3>Registering the Event Listener</h3><p>To ensure that our event listener is registered and listening for events, open the “EventServiceProvider.php&quot; file in the &quot;app/Providers&quot; directory. Add the following line to the &quot;$listen&quot; array:</p><pre>&lt;?php<br>// app/Providers/EventServiceProvider.php<br><br>namespace App\Providers;<br><br>use Illuminate\Auth\Events\Registered;<br>use Illuminate\Auth\Listeners\SendEmailVerificationNotification;<br>use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;<br>use Illuminate\Support\Facades\Event;<br><br>class EventServiceProvider extends ServiceProvider<br>{<br>     protected $listen = [<br>         FoodOrderedEvent::class =&gt; [<br>             OrderListener::class,<br>         ],<br>         Registered::class =&gt; [<br>              SendEmailVerificationNotification::class,<br>        ],<br>    ];<br>    <br>    ....<br>}</pre><p>This configuration tells Laravel to listen for “FoodOrderedEvent&quot; events and handle them using the &quot;OrderListener&quot; listener.</p><h3>Triggering the Event</h3><p>Now, we need to trigger the “FoodOrderedEvent&quot; event when a user places an order. Update the &quot;web.php&quot; file to define a route that handles food orders.</p><pre>// routes/web.php<br><br>Route::post(&#39;/order/{item}&#39;, function ($item) {<br>    event(new FoodOrderedEvent($item));<br>    return redirect(&#39;/&#39;);<br>})-&gt;name(&#39;order&#39;);</pre><p>In this route, we use the “event” helper function to fire the “FoodOrderedEvent&quot; event with the selected item as a parameter. After triggering the event, we redirect the user back to the menu.</p><h3>Testing the Application</h3><p>Finally, you can start your Laravel development server and visit http://localhost:8000 to explore the food menu and place orders. Each time an order is placed, the event listener will log a message in the Laravel log files.</p><pre>php artisan serve</pre><h3>Conclusion</h3><p>Event-based development in Laravel provides a powerful way to decouple components of your application and handle various tasks asynchronously. In this example, we’ve seen how to create a simple food ordering system using Laravel events. You can extend this concept to build more complex and interactive applications with ease. Events are a fundamental tool in Laravel’s toolkit, enabling you to create elegant and responsive web applications. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ed35c054445" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting Up a Laravel Project on Ubuntu VPS with Nginx, Let’s Encrypt, and MariaDB]]></title>
            <link>https://medium.com/@stahiralijan/setting-up-a-laravel-project-on-ubuntu-vps-with-nginx-lets-encrypt-and-mariadb-8f6eaeeeb653?source=rss-bb1da8b6bb14------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f6eaeeeb653</guid>
            <dc:creator><![CDATA[Syed Tahir Ali Jan]]></dc:creator>
            <pubDate>Fri, 29 Sep 2023 13:44:14 GMT</pubDate>
            <atom:updated>2023-09-29T13:45:04.917Z</atom:updated>
            <content:encoded><![CDATA[<p>This article was originally published on tahirjan.com on March 25th, 2018:</p><p><a href="https://tahirjan.com/setting-up-a-laravel-project-on-ubuntu-vps-with-nginx-lets-encrypt-and-mariadb/">Setting Up a Laravel Project on Ubuntu VPS with Nginx, Let&#39;s Encrypt, and MariaDB - Syed Tahir Ali Jan</a></p><p>Are you ready to take your Laravel project live on the web? If you’re running your application on an Ubuntu VPS and want to ensure secure and efficient hosting, you’ve come to the right place. In this guide, we’ll walk through the process of setting up your Laravel project with Nginx, Let’s Encrypt for HTTPS, and MariaDB for your database.</p><p>This is a no complex straightforward fastest deployment setup for learning purposes only, for a more managed approach, you have to setup CI/CD pipeline with test, staging, and production servers.</p><h3>Prerequisites</h3><p>Before we dive in, make sure you have the following:</p><ul><li>An Ubuntu-based VPS (Virtual Private Server) with SSH access.</li><li>A Laravel project ready to deploy.</li><li>A domain name pointed to your VPS’s IP address.</li></ul><h4>Step 1: SSH into Your VPS</h4><blockquote><em>If you’re using Windows, you can use PowerShell or </em><a href="https://www.putty.org/"><em>PuTTY</em></a><em> to connect to your server.</em></blockquote><p>Open your terminal and SSH into your VPS by running the following command:</p><p>ssh username@your_server_ip</p><p>Replace username with your server&#39;s username and your_server_ip with your VPS&#39;s IP address.</p><h4>Step 2: Update and Upgrade</h4><p>Let’s ensure your server is up to date. Run these commands:</p><pre>sudo apt update<br><br>sudo apt upgrade</pre><p>This ensures that you have the latest package information and updates installed.</p><h4>Step 3: Install Nginx</h4><p>Nginx is a powerful web server and reverse proxy that we’ll use to serve your Laravel application. Install it with:</p><pre>sudo apt -y install nginx</pre><p>Once Nginx is installed, start and enable it:</p><pre>sudo systemctl start nginx<br><br>sudo systemctl enable nginx</pre><h4>Step 4: Install MariaDB</h4><p>MariaDB is an excellent choice for your database needs. Install it with:</p><pre>sudo apt install -y mariadb-server mariadb-client</pre><p>During the installation, you’ll be prompted to set a root password. Make sure to choose a strong one.</p><p>Start and enable MariaDB:</p><pre>sudo systemctl start mariadb<br>			<br>sudo systemctl enable mariadb</pre><p>You can secure your MariaDB installation by running, the command-line installation wizard will guide you through the process and ask for your inputs:</p><pre>sudo mysql_secure_installation</pre><h4>Step 5: Create a Database and User</h4><p>Log into the MariaDB shell as the root user:</p><pre>sudo mysql -u root -p</pre><p>Create a database for your Laravel project. Replace dbname with your desired database name:</p><pre>CREATE DATABASE dbname;</pre><p>Create a user and grant privileges. Replace username and password with your chosen credentials:</p><pre>CREATE USER &#39;username&#39;@&#39;localhost&#39; IDENTIFIED BY &#39;password&#39;;<br><br>GRANT ALL PRIVILEGES ON dbname.* TO &#39;username&#39;@&#39;localhost&#39;;<br><br>FLUSH PRIVILEGES;<br><br>EXIT;</pre><h4>Step 6: Install PHP and Required Extensions</h4><p>Install PHP and necessary extensions:</p><pre>sudo apt install -y php-fpm php-mysql php-json php-curl php-mbstring php-xml php-zip</pre><h4>Step 7: Configure Nginx</h4><p>Create a new Nginx server block configuration file for your Laravel project:</p><pre>sudo nano /etc/nginx/sites-available/laravel</pre><p>Add the following configuration, replacing your_domain with your domain name and your_project_path with the path to your Laravel project&#39;s public directory:</p><pre>server {<br>	listen 80;<br>	server_name your_domain;<br><br>	root /your_project_path/public;<br>	index index.php;<br><br>	location / {<br>		try_files $uri $uri/ /index.php?$query_string;<br>	}<br><br>	location ~ \.php$ {<br>	        include snippets/fastcgi-php.conf;<br>	      	fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;<br>      	}<br><br>	location ~ /\.ht {<br>		deny all;<br>	}<br><br>	error_log /var/log/nginx/laravel_error.log;<br>	access_log /var/log/nginx/laravel_access.log;<br>}</pre><p>Save the file and create a symbolic link to enable the configuration:</p><pre>sudo ln -s /etc/nginx/sites-available/laravel /etc/nginx/sites-enabled/</pre><p>Test the configuration:</p><pre>sudo nginx -t</pre><p>If the test is successful, reload Nginx:</p><pre>sudo systemctl reload nginx</pre><h4>Step 8: Install Let’s Encrypt Certificates</h4><p>To secure your Laravel project with HTTPS, we’ll use Let’s Encrypt. Install the Certbot client:</p><pre>sudo apt install -y certbot python3-certbot-nginx</pre><p>Obtain and install a certificate for your domain:</p><pre>sudo certbot --nginx -d your_domain</pre><p>Follow the prompts to configure Nginx to use the certificate.</p><h3>Step 9: Configure Laravel .env</h3><p>Navigate to your Laravel project directory and edit the .env file to configure your database settings:</p><pre>cd /your_project_path<br>			<br>nano .env</pre><p>Update the DB_DATABASE, DB_USERNAME, and DB_PASSWORD fields with your database information.</p><h4>Step 10: Assign Proper permissions:</h4><p>Run the following commands to set the proper file permissions:</p><pre>sudo chown -R www-data:www-data /your_project_path <br><br>sudo chown -R 755 /your_project_path/bootstrap<br><br>sudo chmod -R 755 /your_project_path/storage</pre><h4>Step 11: Migrate and Seed</h4><p>Run Laravel’s migration and seeding commands to set up your database:</p><pre>php artisan migrate<br>			<br>php artisan db:seed</pre><h4>Step 12: Restart Nginx and PHP-FPM</h4><p>Restart Nginx and PHP-FPM to apply the changes:</p><pre>sudo systemctl restart nginx<br>			<br>sudo systemctl restart php7.2-fpm</pre><h4>Step 13: Access Your Laravel Project</h4><p>Open your web browser and visit your domain over HTTPS. You should see your Laravel project up and running, securely hosted on your Ubuntu VPS.</p><p>Congratulations! You’ve successfully set up a Laravel project on an Ubuntu VPS using Nginx, Let’s Encrypt for HTTPS, and MariaDB. Your project is now live on the web and ready for the world to see. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f6eaeeeb653" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The magic of extract() function in PHP]]></title>
            <link>https://medium.com/@stahiralijan/the-magic-of-extract-function-in-php-eea727f289a9?source=rss-bb1da8b6bb14------2</link>
            <guid isPermaLink="false">https://medium.com/p/eea727f289a9</guid>
            <dc:creator><![CDATA[Syed Tahir Ali Jan]]></dc:creator>
            <pubDate>Fri, 29 Sep 2023 10:56:00 GMT</pubDate>
            <atom:updated>2023-09-29T10:56:00.465Z</atom:updated>
            <content:encoded><![CDATA[<p>This article was originally published on <a href="https://tahirjan.com">https://tahirjan.com</a> on <em>February 27, 2019</em></p><p><a href="https://tahirjan.com/the-magic-of-extract-function-in-php/">The magic of extract() function in PHP - Syed Tahir Ali Jan</a></p><p>PHP is a versatile language, it offers numerous functions that simplify coding tasks. One of which is extract(), which can be a powerful tool in your PHP toolkit. In this article, we will delve into the extract() function, explore its uses, and provide code examples to illustrate its practical applications.</p><h3>Understanding extract()</h3><p>The extract() function in PHP is used to import variables from an associative array into the current symbol table. It effectively transforms array keys into variable names and assigns their corresponding values to these variables. This can be especially handy when you need to work with data retrieved from forms, databases, or other sources.</p><p>Syntax:</p><pre>extract(array, extract_type, prefix);</pre><ul><li>array: The source array containing key-value pairs to extract as variables.</li><li>extract_type (optional): A constant that specifies how to handle naming conflicts.</li><li>prefix (optional): A string to prepend to the variable names.</li></ul><h3>Use Cases and Examples</h3><p>Let’s explore some common scenarios where the extract() function can be useful.</p><h4>Scenario 1: Handling Form Data</h4><p>When processing data submitted through an HTML form, you often receive an associative array with input names as keys and user-submitted values as values. extract() can help simplify the code.</p><pre>// Simulated form data <br><br>$data = [&#39;name&#39; =&gt; &#39;John Doe&#39;, &#39;email&#39; =&gt; &#39;john@example.com&#39;, &#39;age&#39; =&gt; 30]; <br><br>extract($data); <br><br>echo $name; // Output: John Doe <br>echo $email; // Output: john@example.com<br>echo $age; // Output: 30</pre><h4>Scenario 2: Working with Database Results</h4><p>When fetching data from a database, you often receive rows as associative arrays. extract() can make your code more concise.</p><pre>// Simulated database result <br>$row = [&#39;id&#39; =&gt; 101, &#39;product_name&#39; =&gt; &#39;Widget X&#39;, &#39;price&#39; =&gt; 19.99, ];<br><br>extract($row); <br><br>echo $id; // Output: 101 <br>echo $product_name; // Output: Widget X <br>echo $price; // Output: 19.99p</pre><h4>Scenario 3: Avoiding Naming Conflicts</h4><p>You can use the optional extract_type parameter to resolve the naming conflicts when extracting variables.</p><pre>$user = &#39;Alice&#39;; <br>$conflictingData = [ &#39;user&#39; =&gt; &#39;Bob&#39;, &#39;message&#39; =&gt; &#39;Hello, World!&#39;, ]; <br><br>extract($conflictingData, EXTR_OVERWRITE); echo $user; // Output: Bob echo<br><br>$message; // Output: Hello, World!</pre><p>By setting EXTR_OVERWRITE, the variable $user is overwritten with the value from the array.</p><h3>Scenario 4: Using a Prefix</h3><p>To prevent variable name clashes with existing variables, you can specify a prefix.</p><pre>$existingVar = &#39;This will not be overwritten&#39;; <br><br>$data = [&#39;existingVar&#39; =&gt; &#39;This is safe&#39;, &#39;newVar&#39; =&gt; &#39;Hello, PHP!&#39;,]; <br><br>extract($data, EXTR_PREFIX_ALL, &#39;prefix&#39;); <br><br>echo $existingVar; // Output: This will not be overwritten <br>echo $prefix_existingVar; // Output: This is safe <br>echo $prefix_newVar; // Output: Hello, PHP!</pre><p>By adding the prefix ‘prefix_’, you ensure that extracted variables won’t conflict with existing ones.</p><p>The extract() function in PHP is a powerful tool for simplifying code when working with associative arrays. It allows you to transform array keys into variable names effortlessly. However, it should be used with caution to avoid unexpected variable clashes. By understanding its usage and applying it judiciously, you can streamline your PHP code and make it more efficient when dealing with data from various sources.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eea727f289a9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel: String manipulations with ‘Str’ class]]></title>
            <link>https://medium.com/@stahiralijan/laravel-string-manipulations-with-str-class-215805b6adbb?source=rss-bb1da8b6bb14------2</link>
            <guid isPermaLink="false">https://medium.com/p/215805b6adbb</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[string-manipulation]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Syed Tahir Ali Jan]]></dc:creator>
            <pubDate>Sun, 04 Feb 2018 14:22:03 GMT</pubDate>
            <atom:updated>2018-04-07T02:46:26.553Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*ROhfFzxR7AUahSY4Fr3dhg.jpeg" /><figcaption>Laravel: String manipulations with ‘Str’ class <a href="https://programiz.com">https://programiz.com</a></figcaption></figure><p>Laravel already provides powerfull helpers for string manipulations, but I was wondering what’s behind these convinient helpers. The Laravel string helpers is powered by Illuminate\Support\Str class. Let&#39;s explore what methods it contains and how we can use them. For this example I will be using <em>&#39;Lorem Ipsm ....&#39;</em> for subject testing. Here&#39;s the list of all the methods used, you can jump right to your desired method from here:</p><h3>1- after($subject, $search) : string</h3><p>This method chops off all the characters including $search from the start in the $subject and returns the rest of the string. Let&#39;s test this method:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*2_kliR6YF-srKTSPqLC39Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*kePLh73kUcb_HRggYydtoA.png" /></figure><h3>2- ascii($value, $language = ‘en’) : string</h3><p>This method returns the ascii equivalent of the $value string in the $language specified.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*98CF2Zxa0lf0_V4D3QKbRw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*N7LkFXJJgCKPsFIPkuf7CA.png" /></figure><h3>3- before($subject, $search) : string</h3><p>This is opposite of after() method. This will only keep the characters before the$search characters:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*4goTEPm6vTvHFpiQ5sOp_w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*S3UGK6G1FGDWkQxkdligGA.png" /></figure><h3>4- camel($value) : string</h3><p>This method will return a camel-case string. It will remove any spaces and join the words as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*GcY5di3wvf0VoQ5O4U3ucw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*18XRgv3wQ8Or4FiXlPnrFQ.png" /></figure><h3>5- contains($haystack, $needles) : bool</h3><p>This method returns boolean true or false if a string $haystack contains a string / characters $needles. This is a case-sensitive method, means if it has a work &#39;tomorrow&#39;, it will return false for &#39;Tomorrow&#39; as demonstrated below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*fuJK7f5St3FTTqncXzwvtg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*3VanPh-YR3GIeMxeCg-Dog.png" /></figure><h3>6- endsWith($haystack, $needles) : bool</h3><p>This method tests if $haystack ends with $needles which can be a string or an array. Let’s check the example below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*NLgHTsmqTAYyzyoI-RKlsQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*7FQ-nEiIH7bzdpcqXA0oGg.png" /></figure><h3>7- finish($value, $cap) : string</h3><p>This method add a padding to the end of the string. In other words, right-pad the string, as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*BnPNHGcr6g1zIzEHQ7nGVQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*5ldj6w8DhKo7PIk1e6-GtA.png" /></figure><h3>8- is($pattern, $value) : bool</h3><p>This method tests $value against the $pattern which can be a string or an array of strings and returns true or false if the string contains the pattern. As shown below in the example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*0gtyaVcTNdA21Yffz4t7aw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*e0qiMnWl45zAmAyucN3ZJw.png" /></figure><h3>9- kebab($value) : string</h3><p>This method turns your string into a kebab-case string.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*fkU4ONl8G3NpFeEpw32RHA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*mh09OrOCy992epgBYFKx1g.png" /></figure><h3>10- length($value, $encoding = null) : int</h3><p>This method uses <strong>mbstring</strong> extension’s <strong>mb_strlen()</strong> function for length, for non-ascii (Unicode) strings you have to provide $encoding scheme name such as UTF-8, UTF-16 etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*8qEdYrHKyNfbO_-rv48NiQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*tGk6qEeJfG5HBrmPo_y6ZQ.png" /></figure><h3>11- limit($value, $limit = 100, $end = ‘…’) : string</h3><p>This method limits the string at a $limit, the default value for limit is 100 characters which is excluding the $end text.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*R5U_u8LbrrmSNaD1TvQlgQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*uSEcE_7R-ECOhzTKWcliKQ.png" /></figure><h3>12- lower($value) : string</h3><p>This method converts the string to a lower-case string.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*IJAfG1FJ3WdcsiVFn7ybaw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*k0WlOyaAOhbQ3T05p6PNqg.png" /></figure><h3>13- words($value, $words = 100, $end = ‘…’) : string</h3><p>This method limits the string to the number of words just like limit() method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*ZlB_uuglTTte-yLl5gJNfA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*KqKThcQvmMXykAnmvUhy3w.png" /></figure><h3>14- plural($value, $count = 2) : string</h3><p>This method converts a given word or last word of the string to plural form.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*r0bPzPxaPTo4GyPcF_tKww.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*32Ur_hxOS9189gn5Lo5lRw.png" /></figure><h3>15- random($length = 16) : string</h3><p>This method generates a random string, the default length of the returned string is 16.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*7ol30D2tVtdG26gE9AzO8g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/1*NjdS1iNpZZ1vqpkFI7aFOw.png" /></figure><h3>16- replaceArray($search, array $replace, $subject)</h3><p>This method replaces all the instances of $search in $subject with $replace in a starting order, you will get more clarity with the following example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*LDbK52Uta9WuAJyBzHykqg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*goTZ-wWU5DvWmZ2y_l_DiA.png" /></figure><h3>17- replaceFirst($search, $replace, $subject) : string</h3><p>This method will only replace the first occurance of $search with $replace in the $subject string as shown in the example below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*lK2juHcEg295BnF-vsxGyg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*SPs9du8C0ITzvJ6b8t3xQA.png" /></figure><h3>18- replaceLast($search, $replace, $subject) : string</h3><p>Like replaceFirst() this method replaces the last occurance of $search with $replace in the $subject string.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*9q2Nq63rOdT0-NP8ocpzZQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*-F5VKnhuXVbbLF00uZ3S3A.png" /></figure><h3>19- start($value, $prefix) : string</h3><p>This method adds $prefix to the starting of the $value. In other words it left-pads the string.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*7sWQSVsYzX2zjFcZze6Ucw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*ar3njezazTkWeJUPAtg66g.png" /></figure><h3>20- upper($value) : string</h3><p>This method converts $value to upper-case string. It uses mb_strtoupper().</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*uqxL4K-NlxdPLLNabyPQjw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*5ON440Y-ubGfDom073ypLQ.png" /></figure><h3>21- title($value) : string</h3><p>This method converts $value to title-case string.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*i4L5PRv4FgeVpj40SM1KAQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*jS3FCF2hQ55yktQW9XoScg.png" /></figure><h3>22- singular($value) : string</h3><p>Opposite ofplural() method, it converts plural word $valule into a singular word.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*tQShKrsGHAEsNkjDJPXcgQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*b2EAEI2SuAbqmN__ZdSyqg.png" /></figure><h3>23- slug($title, $separator = ‘-’, $language = ‘en’) : string</h3><p>Turns given string into a slug-case string which can be useful for SEO friendly urls. It will remove any non-printable characters, special characters and convert unicode into ascii characters.</p><p>By default, the separator used is ‘-’ but you can specify your own, like I used a ‘+’ sign:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*CvpfwMSDqWJTy86vXkCwfg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*6fsTK4oOcpzysiK_meq3sw.png" /></figure><h3>24- snake($value, $delimiter = ‘_’) : string</h3><p>This method will convert the string $value into a snake-case string with $delimiter specified, an _ will be used if unspecified.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*alw_z5y2MQzCcy-TcpnQYQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*_mi3ApCseMteDDM4gSxLWw.png" /></figure><h3>25- startsWith($haystack, $needles) : bool</h3><p>This method tests if a given string $haystack starts with a string or one of strings in the array $needles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*5tYUhtdPFRYZbYPDE0Qf3w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*qXdM1gzLsT4H-tKuX6qfRg.png" /></figure><h3>26- studly($value) : string</h3><p>This method will return a studly-case string of $value.</p><p>This method returns a sub-string of a $string from position $start, $length is optional but you can specify to return the number of characters to be return, it will return the rest of the string if not specified.</p><p>This method uses mbstring’s mb_substr() function:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*TIp1aJAf6XYEurqCAjYJmA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*vWbKQOiCIX5tcvWXRQzDWg.png" /></figure><h3>28- ucfirst($string) : string</h3><p>I don’t know how this method compares to the PHP native ucfirst() function in terms of speed and memory usage but it’s there. This method capitalizes the first character / letter of the string given.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*TOYGAmJhNoJs0UE3NMuBcg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*vrpSecE3TIOLBgO6REMd6Q.png" /></figure><p><em>Originally published at </em><a href="https://tahirjan.com/laravel-string-manipulations-with-str-class/"><em>tahirjan.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=215805b6adbb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel: Add @method() & @csrf to Blade]]></title>
            <link>https://medium.com/@stahiralijan/laravel-add-method-csrf-to-blade-b65d13eacf5a?source=rss-bb1da8b6bb14------2</link>
            <guid isPermaLink="false">https://medium.com/p/b65d13eacf5a</guid>
            <category><![CDATA[blade]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Syed Tahir Ali Jan]]></dc:creator>
            <pubDate>Fri, 02 Feb 2018 04:49:39 GMT</pubDate>
            <atom:updated>2018-02-02T06:50:13.031Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qoZOWgX5aOKNCJhmPiHYww.png" /><figcaption>Copyright: https://laravel-news.com</figcaption></figure><p>Taylor Otwell tweeted about his plans to add @method() and @csrf. I&#39;m currently using Laravel 5.5 so I have to add these to a ServiceProvider to make use of it. This tutorial discusses how to add such helpers to your edition of Laravel.</p><p>Let’s start right off from creating a ServiceProvider:</p><pre><strong>php artisan</strong> make:provider BladeServiceProvider</pre><p>or just create a class called BladeServiceProvider in your app\Providers directory and add the following code:</p><pre>&lt;?php</pre><pre><strong>namespace</strong> App\Providers;</pre><pre><strong>use</strong> Illuminate\Support\ServiceProvider;</pre><pre><strong>class</strong> BladeServiceProvider <strong>extends </strong>ServiceProvider</pre><pre>{<br>    /**<br>    * Bootstrap the application services. <br>    *<br>    * @return void <br>    */<br>    <strong>public function</strong> boot()<br>    {<br>        //<br>    }</pre><pre>    /**<br>     * Register the application services. <br>     * <br>     * @return void <br>     */<br>     <strong>public function</strong> register()<br>     {<br>         //<br>     }<br>}</pre><p>Now let’s add logic for @method in the boot method of BladeServiceProvider</p><pre>Blade::directive(&#39;method&#39;, <strong>function</strong> ($method) {<br>    <strong>return</strong> &#39;&lt;input type=&quot;hidden&quot; name=&quot;_method&quot; value=&quot;&lt;?php <strong>echo</strong> strtoupper(&#39; . $method . &#39;); ?&gt;&quot;&gt;&#39;;</pre><pre>});</pre><p>Now let’s add logic for @csrf helper like above.</p><pre>Blade::directive(&#39;csrf&#39;, function () {</pre><pre><strong>    return</strong> &#39;&lt;?php echo csrf_field(); ?&gt;&#39;;</pre><pre>});</pre><p>Your code should look similar to the following:</p><pre>&lt;?php</pre><pre><strong>namespace</strong> App\Providers;</pre><pre><strong>use</strong> Blade;<br><strong>use</strong> Illuminate\Support\ServiceProvider;</pre><pre><strong>class</strong> BladeServiceProvider <strong>extends</strong> ServiceProvider<br>{<br>    /**<br>     * Bootstrap the application services. <br>     *<br>     * @return void <br>     */<br>     <strong>public function</strong> boot()<br>     {<br>        Blade::directive(&#39;csrf&#39;, function () {<br>            <strong>return</strong> &#39;&lt;?php echo csrf_field(); ?&gt;&#39;;<br>        });</pre><pre>        Blade::directive(&#39;method&#39;, function ($method) {<br>            <strong>return</strong> &#39;&lt;input type=&quot;hidden&quot; name=&quot;_method&quot; value=&quot;&lt;?php <strong>echo</strong> strtoupper(&#39; . $method . &#39;); ?&gt;&quot;&gt;&#39;;<br>        });<br>     }</pre><pre>     /** <br>      * Register the application services. <br>      * <br>      * @return void <br>      */<br>      <strong>public function</strong> register()<br>      {<br>          //<br>      }<br>}</pre><p>Now add BladeServiceProvider::class to the providers array in your config\app.php file like this:</p><pre>&#39;providers&#39; =&gt; [<br>    ...</pre><pre>    App\Providers\BladeServiceProvider::class,</pre><pre>    ...</pre><p>Now finally, you can add @method() and @csrf in Blade template conveniently like this:</p><pre>&lt;<strong>form</strong> <strong>action</strong>=&quot;...&quot; <strong>class</strong>=&quot;...&quot;&gt;<br>    @csrf<br>    @method(&#39;put&#39;)<br>    @hidden(&#39;user_id&#39;,$user-&gt;id)<br>    &lt;<strong>input</strong> <strong>type</strong>=&quot;first_name&quot; <strong>name</strong>=&quot;first_name&quot;&gt;<br>&lt;/<strong>form</strong>&gt;</pre><p>Thanks for reading!</p><p><em>Originally published at </em><a href="https://tahirjan.com/laravel-add-method-and-csrf-to-blade/"><em>tahirjan.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b65d13eacf5a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel: Clearing Cache with a click of a button (Artisan Shortcuts)]]></title>
            <link>https://medium.com/quick-code/laravel-clearing-cache-with-a-click-of-a-button-artisan-shortcuts-b528f55028f8?source=rss-bb1da8b6bb14------2</link>
            <guid isPermaLink="false">https://medium.com/p/b528f55028f8</guid>
            <category><![CDATA[artisan]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[cache]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Syed Tahir Ali Jan]]></dc:creator>
            <pubDate>Thu, 01 Feb 2018 18:00:48 GMT</pubDate>
            <atom:updated>2023-03-16T14:06:47.203Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*W1CgxUGcGPymni2O228cZQ.jpeg" /><figcaption>Copyright: <a href="https://blog.42mate.com">https://blog.42mate.com</a></figcaption></figure><p>In this tutorial we will learn how to purge compiled views and cache by using Laravel Commands.</p><p>Switching back and forth between applications might be cumbersome during development for some folks who have a single monitor. Thanks to the commands in Laravel, we can create and call those commands from anywhere.</p><p><strong>Before you begin,</strong> keep in mind that you should only use this method for Development purposes. Because purging and re-caching might effect your site’s performance</p><p>Let’s start by creating a controller for our operations like this:</p><pre>php artisan make:controller DevClearCacheController</pre><p>Now add following methods to DevClearCacheController class like this:</p><pre>&lt;?php</pre><pre>namespace App\Controllers;</pre><pre><strong>class</strong> DevClearCacheController <strong>extends</strong> Controller<br>{<br>    <strong>public function</strong> clear_views()<br>    {<br>        \Artisan::call(&#39;view:clear&#39;);</pre><pre><strong>        return</strong> redirect()-&gt;back()-&gt;with(&#39;status&#39;,&#39;Views Cleared!&#39;);<br>    }</pre><pre><strong>    public function</strong> clear_cache()<br>    {<br>        \Artisan::call(&#39;cache:clear&#39;);</pre><pre><strong>        return</strong> redirect()-&gt;back()-&gt;with(&#39;status&#39;,&#39;Cache Cleared!&#39;);<br>    }</pre><pre>    // you can also add methods for queue:start, queue:restart etc.<br>}</pre><p>Now let’s add these to the web.php file in the routes directory.</p><pre>&lt;?php</pre><pre>...</pre><pre>Route::get(&#39;clear-views&#39;, &#39;<a href="https://tahirjan.com/cdn-cgi/l/email-protection">[email protected]</a>_views&#39;)<br>     -&gt;name(&#39;clear-views&#39;);</pre><pre>Route::get(&#39;clear-cache&#39;, &#39;<a href="https://tahirjan.com/cdn-cgi/l/email-protection">[email protected]</a>_cache&#39;)<br>    -&gt;name(&#39;clear-cache&#39;);</pre><pre>...</pre><p>Now, let’s create a view that contains our buttons (I prefer to add these in navbar):</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;{{ App::getLocale() }}&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;utf-8&quot;&gt;<br>    &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;<br>    &lt;meta name=&quot;csrf-token&quot; content=&quot;{{ csrf_token() }}&quot;&gt;<br>    &lt;title&gt;{{ config(&#39;app.name&#39;, &#39;Artisan Shortcuts&#39;) }}&lt;/title&gt;    &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css&quot;&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>&lt;nav class=&quot;navbar navbar-inverse navbar-fixed-top&quot;&gt;<br>    &lt;div class=&quot;container&quot;&gt;<br>        &lt;div class=&quot;navbar-header&quot;&gt;<br>            &lt;ul class=&quot;nav navbar-nav&quot;&gt;<br>            &lt;li&gt;<strong>&lt;a href=&quot;{{ route(&#39;clear-views&#39;) }}&quot;&gt;Clear Views&lt;/a&gt;</strong>&lt;/li&gt;<br>            &lt;li&gt;<strong>&lt;a href=&quot;{{ route(&#39;clear-cache&#39;) }}&quot;&gt;Clear Cache&lt;/a&gt;</strong>&lt;/li&gt;<br>            &lt;/ul&gt;<br>        &lt;/div&gt;&lt;!--/.nav-collapse --&gt;<br>    &lt;/div&gt;<br>&lt;/nav&gt;<br>&lt;div class=&quot;body-content&quot;&gt;<br>@if (session(&#39;status&#39;))<br>&lt;div class=&quot;alert alert-success&quot;&gt;{{ session(&#39;status&#39;) }}&lt;/div&gt; @endif<br>&lt;p&gt;Test App&lt;/p&gt;<br>&lt;/div&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Now let’s test our application, the result will be similar to the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_0O-1u26FPtCVzd6uFyCnA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cWwxCcpRV3-2xPn3mgi5qw.png" /></figure><p><em>Originally published at </em><a href="https://tahirjan.com/laravel-clearing-cache-with-a-click-of-a-button/"><em>tahirjan.com</em></a><em>.</em></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fd083d1%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2Fd083d1%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/fc78cb15c51ca2cbc387138848d5e91f/href">https://medium.com/media/fc78cb15c51ca2cbc387138848d5e91f/href</a></iframe><p><strong>Please click 👏 button below a few times to show your support! ⬇⬇ Thanks!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b528f55028f8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/quick-code/laravel-clearing-cache-with-a-click-of-a-button-artisan-shortcuts-b528f55028f8">Laravel: Clearing Cache with a click of a button (Artisan Shortcuts)</a> was originally published in <a href="https://medium.com/quick-code">Quick Code</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Custom events in Vue with $emit and Responsive Image goodness]]></title>
            <link>https://medium.com/@stahiralijan/custom-events-in-vue-with-emit-and-responsive-image-goodness-38aee9d0b2ac?source=rss-bb1da8b6bb14------2</link>
            <guid isPermaLink="false">https://medium.com/p/38aee9d0b2ac</guid>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[html-css]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[vue]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[Syed Tahir Ali Jan]]></dc:creator>
            <pubDate>Tue, 23 Jan 2018 11:34:40 GMT</pubDate>
            <atom:updated>2018-01-23T12:14:13.191Z</atom:updated>
            <content:encoded><![CDATA[<p>Vue provides great functionality when creating components. One great thing is $emit. You can not only trigger a custom event but you can also send data through it.</p><p>This article discusses the use of $emit with the implementation of responsive-image like we see in medium.com articles, the result will be similar to the image below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KEJgx6AGfqcIQOVj.gif" /><figcaption>Finished Product</figcaption></figure><p>According to Vuejs.org:</p><blockquote><strong><em>$emit:</em></strong><em> Trigger an event on the current instance. Any additional arguments will be passed into the listener’s callback function.</em></blockquote><p>Lets implement a responsive image in Vue to utilize the $emit functionality.</p><h3>Step 1:</h3><p>Lets start by a clean html template:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/563d43abd7be7fa7e8f39b522f1a0ebf/href">https://medium.com/media/563d43abd7be7fa7e8f39b522f1a0ebf/href</a></iframe><p>Nothing fancy here.</p><h3>Step 2:</h3><p>Now lets add Vue goodness to it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f71802564691d081c9d0c0643a90cc3/href">https://medium.com/media/7f71802564691d081c9d0c0643a90cc3/href</a></iframe><p>Your result shouldn’t look different that the following image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*20sZmZrArc8HnbGw5yYIZA.png" /><figcaption>Custom events in Vue with $emit and Responsive Image goodness | Initial setup</figcaption></figure><h3>Step 3:</h3><p>Let’s add a basic code to the application so that it will show our low-resolution image only. I’m calling this component, BetterImage.</p><p>As you can notice I’ve also added other properties like orignalUrl, lowresUrl, biWidth, biHeight for future use.</p><blockquote><em>The naming convention of properties in declaration is camelCase while in HTML, the naming convention is kebab-case.</em></blockquote><p>The plan here is that first a low-res image is downloaded, and along-side a high-res image is also downloaded in the background, so that when the high-res image is downloaded, it is then presented with a nice effect.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d778e0925a0663a4fe27cf6edd3f147b/href">https://medium.com/media/d778e0925a0663a4fe27cf6edd3f147b/href</a></iframe><p>As the application is loaded, it will retrive a low-res image. It’s worth mentioning here that I’m using Cloudinary for this example, it gives you a flexible API for image manipulations so you can request an image with specific operation on demand like this:</p><p><a href="http://res.cloudinary.com/YOUR_USER_NAME/image/upload/w_25,q_auto:low/RESOURCE_NAME_WITH_.EXTENSION">http://res.cloudinary.com/YOUR_USER_NAME/image/upload/w_25,q_auto:low/RESOURCE_NAME_WITH_.EXTENSION</a></p><p>Here, w_25 means width of 25 pixels, and q_auto:low means serve me image of low quality. More on this: <a href="https://cloudinary.com/documentation/image_transformations">https://cloudinary.com/documentation/image_transformations</a></p><p>Your image will result will look similar to the image below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FlBCEGaV19ajt9C5UKwBVA.png" /><figcaption>Custom events in Vue with $emit and Responsive Image goodness | Low resoulition image downloaded</figcaption></figure><h3>Step 3 (Final Step):</h3><p>Now we have basic functionality, let’s add the rest of the code.</p><p>What I want for my image, I want to have an image of low quality to show-up first with a blur and desaturated effect while the orignal high-res image is being downloaded in the background, once it is downloaded, the image will have a transition to a colored image and a de-bluring effect, so let’s get right to it:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5226955469092eb15b69bbfa1a996c14/href">https://medium.com/media/5226955469092eb15b69bbfa1a996c14/href</a></iframe><p>The code above shows the use of $emit function which trigger an event called downloaded, we have set</p><p>Our final product will look somthing similar to this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MqJ5z7MOhHa3N202rs76NQ.png" /><figcaption>Custom events in Vue with $emit and Responsive Image goodness | Image downloaded</figcaption></figure><p>Thanks for reading!</p><p><em>Originally published at </em><a href="https://tahirjan.com/custom-events-in-vue-with-dollaremit.html"><em>tahirjan.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38aee9d0b2ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Save time by handling POST, PUT, and DELETE in a single FormRequest in Laravel 5]]></title>
            <link>https://medium.com/@stahiralijan/save-time-by-handling-post-put-and-delete-in-a-single-formrequest-in-laravel-5-9b077a72debc?source=rss-bb1da8b6bb14------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b077a72debc</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[form-request]]></category>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[Syed Tahir Ali Jan]]></dc:creator>
            <pubDate>Sun, 21 Jan 2018 11:45:51 GMT</pubDate>
            <atom:updated>2018-01-22T08:18:01.840Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fplay.ht%2Farticles%2F9b077a72debc&amp;src=https%3A%2F%2Fplay.ht%2Fembed%2F%3Farticle_url%3Dhttps%3A%2F%2Fmedium.com%2F_p%2Fsave-time-by-handling-post-put-and-delete-in-a-single-formrequest-in-laravel-5-9b077a72debc&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=play" width="700" height="185" frameborder="0" scrolling="no"><a href="https://medium.com/media/f17499b221151347cf0aafbf6b6038b5/href">https://medium.com/media/f17499b221151347cf0aafbf6b6038b5/href</a></iframe><blockquote>Imported from: <a href="https://tahirjan.com">tahirjan.com</a></blockquote><p>This article might seem stupid but I was tired of adding FormRequest for common HTTP verb (PUT, POST, DELETE) used in the controller.</p><p>Though separating these files might have their benefits in a large application where other checks are needed to be performed but it was cumbersome for me for small scale applications.</p><p>Let’s learn using an example:</p><pre>&lt;?php</pre><pre>namespace App\Http\Controllers;</pre><pre>class CategoriesController extends Controller<br>{<br>    // Uses GET request<br>    public function index()<br>    {<br>    }<br> <br>    // Uses GET request<br>    public function create()<br>    {<br>    }</pre><pre>    // Uses POST request<br>    public function store(Request $request)<br>    {<br>    }</pre><pre>    // uses GET request<br>    public function edit()<br>    {<br>    }</pre><pre>    // uses PUT request<br>    public function update(Request $request, Category $category)<br>    {<br>    }<br>}</pre><p>Consider you have a CategoriesController like this:</p><p>You can create separate FormRequest (CreateCategoryFormRequest, UpdateCategoryFormRequest, DeleteCategoryFormRequest) files for every type of request, or if you&#39;re like me, you can create only one FormRequest file and handle every type of request within the file.</p><p>What I’d do next is create a FormRequest like this:</p><pre><strong>php artisan</strong> make:request CategoryFormRequest</pre><p>this will generate the following class in the Requests directory of your Laravel application.</p><pre>&lt;?php</pre><pre>namespace App\Http\Requests;</pre><pre>use Illuminate\Foundation\Http\FormRequest;</pre><pre>class <strong>CategoryFormRequest</strong> extends <strong>FormRequest<br></strong>{<br>   /**<br>    * Determine if the user is authorized to make this request.<br>    *<br>    * @return bool <br>    */<br>    public function <strong>authorize</strong>()<br>    {<br>        return <strong>false</strong>;<br>    }</pre><pre>   /**<br>    * Get the validation rules that apply to the request.<br>    *<br>    * @return <strong>array<br>    </strong>*/<br>    public function <strong>rules</strong>()<br>    {<br>        return [<br>            //<br>        ]; <br>    }<br>}</pre><p>As you can see, you get a plain class. Now I’d add a switch statement to handle different requests:</p><pre>&lt;?php</pre><pre>namespace App\Http\Requests;</pre><pre>use Illuminate\Foundation\Http\FormRequest;</pre><pre>class <strong>CategoryFormRequest</strong> extends <strong>FormRequest<br></strong>{<br>  /** <br>   * Determine if the user is authorized to make this request. <br>   *<br>   * @return bool <br>   */<br>   <br>   public function authorize()<br>   {<br>      // an extra layer of security,<br>      // you can check for user role and permission to check if<br>      // user can do this particular task here,<br>      // you can also skip it by <strong>return true;<br>      </strong>if(auth()-&gt;check())<br>      {<br>          // I&#39;m using<strong> Entrust</strong> for user role management<br>          $user = auth()-&gt;user();<strong><br>          </strong>switch($this-&gt;getMethod)<br>          {<br>              case &#39;post&#39;:<br>              case &#39;POST&#39;:<br>                return $user-&gt;hasPermission(&#39;create-category&#39;);</pre><pre>              case &#39;put&#39;:<br>              case &#39;PUT&#39;:<br>                return $user-&gt;hasPermission(&#39;update-category&#39;);<br> <br>              case &#39;DELETE&#39;:<br>              case &#39;delete&#39;:<br>                return $user-&gt;hasPermission(&#39;delete-category&#39;);<br>           }<br>        }<br>        return false;<br>      }</pre><pre>      /**<br>       *  Get the validation rules that apply to the request.<br>       *<br>       * @return array <br>       */<br>      public function rules()<br>      {<br>          switch ($this-&gt;getMethod())<br>          {<br>             // handle creates<br>             case &#39;post&#39;:<br>             case &#39;POST&#39;:<br>               return [<br>                 &#39;name&#39; =&gt; &#39;required|unique:categories,name&#39;<br>               ];</pre><pre>             // Handle updates<br>             case &#39;put&#39;:<br>             case &#39;PUT&#39;:<br>               return [<br>                 &#39;category_id&#39; =&gt; &#39;required|exists:categories,id&#39;,<br>                 &#39;name&#39;        =&gt; [<br>                    &#39;required&#39;,<br>                    Rule::unique(&#39;categories&#39;)-&gt;ignore(request(&#39;category_id))<br>                 ];</pre><pre>                 // handle deletions<br>             case &#39;delete&#39;:<br>             case &#39;DELETE&#39;:<br>               return [<br>                 &#39;category_id&#39; =&gt; &#39;required|exists:categories,id&#39;<br>               ];<br>          }<br>          // return empty array for obvious reasons<br>          return [ // ];<br>     }<br>}</pre><p>This is it</p><p><em>Originally published at </em><a href="https://tahirjan.com/save-time-by-handling-post-put-and-delete-in-a-single-formrequest-in-laravel-5.html"><em>tahirjan.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b077a72debc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Separation of Admin Section on a different port in Laravel 5.x]]></title>
            <link>https://medium.com/@stahiralijan/separation-of-admin-section-on-a-different-port-in-laravel-5-x-975455264954?source=rss-bb1da8b6bb14------2</link>
            <guid isPermaLink="false">https://medium.com/p/975455264954</guid>
            <category><![CDATA[laravel-routes]]></category>
            <category><![CDATA[ssl]]></category>
            <category><![CDATA[laravel-5]]></category>
            <category><![CDATA[nginx]]></category>
            <dc:creator><![CDATA[Syed Tahir Ali Jan]]></dc:creator>
            <pubDate>Tue, 16 Jan 2018 06:39:53 GMT</pubDate>
            <atom:updated>2018-01-22T08:18:01.133Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fplay.ht%2Farticles%2F975455264954&amp;src=https%3A%2F%2Fplay.ht%2Fembed%2F%3Farticle_url%3Dhttps%3A%2F%2Fmedium.com%2F_p%2Fseparation-of-admin-section-on-a-different-port-in-laravel-5-x-975455264954&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=play" width="700" height="185" frameborder="0" scrolling="no"><a href="https://medium.com/media/a9bf43bba9a7d6094729644592b46a18/href">https://medium.com/media/a9bf43bba9a7d6094729644592b46a18/href</a></iframe><p>I was working on a project where client wanted to have admin area on a separate port for privacy reasons.</p><p>I consulted old friend Google and searched for the any existing implementations. To my dismay, none of the solutions worked for me.</p><p>I then thought about the problem and opened RuoteServiceProvider in app\Providers directory in my project.</p><p>After a detailed inspection of the file, it hit me.</p><p>There is a map() method in this class (RouteServiceProvider) with the following code:</p><pre>public function map()<br>{<br>   $this-&gt;mapApiRoutes();<br>   $this-&gt;mapWebRoutes();<br>}</pre><p>It means you can add your custom routes to it based on condition, so I quickly changed the implementation to the following:</p><pre><strong>public function</strong> map()<br>{<br>   <strong>switch</strong>(request()-&gt;getPort())<br>   {<br><strong>      case 80:<br>      case 8080:<br>      case 443:<br></strong>          $this-&gt;mapApiRoutes();<br>          $this-&gt;mapWebRoutes();<br><strong>          break;</strong><br>     // choose a port that is not used by another server<br>      <strong>case 8975:</strong><br>          $this-&gt;mapAdminWebRoutes();<br><strong>          break;</strong><br>    }<br>}</pre><p>Notice I’m scanning port number now for every request, that will have it’s own implications and a small over-head, also, I was unable to add an SSL certificate to this port as <strong>HTTPS </strong>uses port <strong>443.</strong></p><p><strong>Please do comment if you know any technique to add SSL certificate to custom port or if I’m doing something wrong where</strong></p><p>Now I added the following method maprAdminWebRoutes to RouteServiceProvider class:</p><pre><strong>protected function </strong>mapAdminWebRoutes()<br>{<br>   Route::<strong>middleware</strong>(<strong>&#39;web&#39;</strong>)<br>      -&gt;<strong>namespace</strong>($this-&gt;<strong>namespace</strong>)<br>      -&gt;group(base_path(<strong>&#39;routes/admin-web.php&#39;</strong>));<br>}</pre><p>Then I added admin-web.php file to the routes directory and added my routes to the file.</p><h3>We not done yet!</h3><p>In order for this to work, we also need to add port number to our <strong>nginx</strong> sites-enabled/YOUR-DOMAIN-CONF-FILE.conf file:</p><pre>server {<br>   listen <strong>8975;<br></strong>   server_name YOUR_DOMAIN_NAME;<br>   root &#39;/path/to/your/application/public/;</pre><pre>   ...</pre><p>And that’s pretty much it.</p><p>Now you can access your custom routes on your custom port(s).</p><p>I hope you enjoyed this as much as I did when I implemented this.</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=975455264954" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel FormRequest Mutators / Attribute Casting]]></title>
            <link>https://medium.com/@stahiralijan/laravel-formrequest-attribute-casting-db2fcb794db9?source=rss-bb1da8b6bb14------2</link>
            <guid isPermaLink="false">https://medium.com/p/db2fcb794db9</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[Syed Tahir Ali Jan]]></dc:creator>
            <pubDate>Fri, 12 Jan 2018 17:37:46 GMT</pubDate>
            <atom:updated>2018-01-22T08:18:01.642Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fplay.ht%2Farticles%2Fdb2fcb794db9&amp;src=https%3A%2F%2Fplay.ht%2Fembed%2F%3Farticle_url%3Dhttps%3A%2F%2Fmedium.com%2F_p%2Flaravel-formrequest-attribute-casting-db2fcb794db9&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=play" width="700" height="185" frameborder="0" scrolling="no"><a href="https://medium.com/media/e6ffb9a3bf19d66f49391ec007beef7f/href">https://medium.com/media/e6ffb9a3bf19d66f49391ec007beef7f/href</a></iframe><p>When I was handling form requests in Laravel controller, I felt a need for some intermediate class or a trait in the FormRequest. A a quick Google search revealed that I was not alone but there wasn’t any package available to accomplish what I needed.</p><h3>Why do we need this package?</h3><p>To give you guys idea what I wanted, let’s put what I wanted to accomplish.</p><p>To create/update user’s details I was doing the following.</p><pre>...<br><strong>public</strong> function store(<strong>UserFormRequest</strong> $request)<br>{<br>    $first_name = <em>ucwords(</em>$request-&gt;first_name);<br>    $last_name = <em>ucwords($request-&gt;last_name);<br>    $fullname = $first_name . &#39; &#39; . $last_name;</em></pre><pre>    ...<br>    $user = <strong>User</strong>::create([<br>        ...<br>        &#39;first_name&#39; =&gt; $first_name,<br>        &#39;last_name&#39;  =&gt; $last_name,<br>        ...</pre><pre>    ]);</pre><pre>    ...</pre><pre>    return redirect(route(&#39;users.index&#39;))<br>            -&gt;with([&#39;message&#39; =&gt; &quot;User ({$fullname}) created&quot;]);<br>}</pre><p>I was not happy with the code above because it made my controller method look dirty by putting decorative stuff into the controller, there must be a separation of concern here.</p><p>I thought for a moment and said to myself, I must do something about it and started digging about Laravel Requests. Soon I learned about validate() method that resides in ValidatesWhenResolvedTrait, which is used in FormRequest class.</p><h3>The implementation</h3><p>I began by creating a Trait called RequestCasterTrait and added my casting methods like so:</p><pre>...</pre><pre><strong>protected function </strong>castToLowerCaseWords(): void<br>{<br>    <strong>if </strong>(<em>property_exists</em>($this, <strong>&#39;toLowerCaseWords&#39;</strong>) &amp;&amp; $this-&gt;<strong>toLowerCaseWords</strong>)<br>    {<br>        <strong>foreach </strong>($this-&gt;<strong>toLowerCaseWords as </strong>$key)<br>        {<br>            <strong>if </strong>($this-&gt;<strong>request</strong>-&gt;has($key))<br>            {<br>                $this-&gt;<strong>request</strong>-&gt;set($key, <em>strtolower</em>(request($key)));<br>            }<br>        }<br>    }<br>}</pre><pre>...</pre><p>Now I added another method to calls all the necessary methods:</p><pre><strong>public function </strong>mapCasts(): void<br>{<br>    $this-&gt;castToLowerCaseWords();<br>    $this-&gt;castToUpperCaseWords();<br>    $this-&gt;castUCFirstWords();<br>    $this-&gt;castToSlugs();<br>    $this-&gt;castToInteger();<br>    $this-&gt;castToFloats();<br>    $this-&gt;castToBoolean();<br>    $this-&gt;castJsonToArray();<br><br>    <em>// call this in last so for the fields that need to be casted first<br>    </em>$this-&gt;castJoinFields();<br>}</pre><p>I decided to use the validate() method because it is called before data is either passed back to form with errors or passed to controller. Here is the method in the ValidatesWhenResolvedTrait:</p><pre><strong>trait </strong>ValidatesWhenResolvedTrait<br>{</pre><pre><em>    /**<br>     * Validate the class instance.<br>     *<br>     * </em><strong><em>@return </em></strong><em>void<br>     */<br>    </em><strong>public function </strong>validate()<br>    {<br>        $this-&gt;prepareForValidation();<br><br>        $instance = $this-&gt;getValidatorInstance();<br><br>        <strong>if </strong>(! $this-&gt;passesAuthorization()) {<br>            $this-&gt;failedAuthorization();<br>        } <strong>elseif </strong>(! $instance-&gt;passes()) {<br>            $this-&gt;failedValidation($instance);<br>        }<br>    }<br>    ...</pre><p>I overrided this method to accommodate my needs:</p><pre><strong>public function </strong>validate()<br>{<br>    $this-&gt;prepareForValidation();<br><br>    $instance = $this-&gt;getValidatorInstance();<br><br>    <strong>if </strong>(!$this-&gt;passesAuthorization())<br>    {<br>        $this-&gt;failedAuthorization();<br>    }<br>    <strong>else if </strong>(!$instance-&gt;passes())<br>    {<br>        $this-&gt;failedValidation($instance);<br>    }<br><br>    <strong>if </strong>($instance-&gt;passes())<br>    {<br>        $this-&gt;mapCasts();<br>    }<br>}</pre><p>The casts and conversions will only take place when the validations pass the FormRequest’s rules. And, that’s pretty much it.</p><p>Now let’s start using it in our dummy FormRequest and Controller:</p><h3>UserFormRequest</h3><pre><strong>namespace </strong>App\Http\Requests\Admin;<br><br><strong>use </strong>Stahiralijan\RequestCaster\Traits\RequestCasterTrait;<br><strong>use </strong>Illuminate\Foundation\Http\FormRequest;<br><br><strong>class </strong>UserFormRequest <strong>extends </strong>FormRequest<br>{<br>   <strong>use </strong>RequestCasterTrait;<br><br>   <strong>protected $toUCFirstWords </strong>= [<strong>&#39;first_name&#39;,&#39;last_name&#39;</strong>];<br>   <strong>protected</strong> <strong>$joinStrings</strong> = [<strong>&#39;fullname&#39;=&gt;&#39; |first_name,last_name&#39;</strong>];</pre><pre><strong>   public function </strong>authorize()<br>   {<br>      <strong>return TRUE</strong>;<br>   }</pre><pre><strong>   public function </strong>rules()<br>   {</pre><pre>      <strong>return</strong> [</pre><pre>         &#39;first_name&#39; =&gt; &#39;required&#39;,<br>         &#39;last_name&#39; =&gt; &#39;required&#39;,</pre><pre>      ];</pre><pre>   }</pre><pre>}</pre><p>Let me explain what’s going on here:</p><p>First you need to import the trait by <strong>use </strong>Stahiralijan\RequestCaster\Traits\RequestCasterTrait and then use this trait in the class like shown in the code above.</p><p>Here I wanted to Capitalize first name and last name, and join both names to create a new field called fullname. You can use the following attributes for mutation / casting:</p><ul><li>$toLowerCaseWords: Applies strtolower() to the selected field(s).</li><li>$toUpperCaseWords: Applies strtoupper() to the selected field(s).</li><li>$toUCFirstWords: Applies ucwords() to the selected field(s).</li><li>$toSlugs: Applies str_slug() to the selected field(s).</li><li>$toIntegers: Casts selected field(s) to int.</li><li>$toFloats: Casts selected field(s) to float.</li><li>$toBooleans: Casts selected field(s) to bool.</li><li>$toArrayFromJson: Applies json_decode() to the selected fields.</li></ul><p>$joinStrings is a special attribute that takes joins two or more fields, you can specify joining rule in the following manner:</p><pre><strong>protected</strong> $joinStrings = [<strong>&#39;newFieldName&#39;</strong> =&gt; <strong>&#39;glue|first_field,second_field,....,nthfield&#39;</strong>];</pre><p>The result of the above UserFormRequest for $first_name = &#39;Tahir&#39;; $last_name = &#39;Jan&#39;; will be $fullname = &#39;Tahir Jan&#39;; as we have provided a space &#39; &#39; for a glue. Now lets see how we can use the UserFormRequest in our controller’s store method:</p><pre><strong>public </strong>function store(<strong>UserFormRequest </strong>$request)<br>{</pre><pre>   // Here first_name will be &#39;Tahir&#39; even if user submitted &#39;tahir&#39;<br>   // for other casted fields you get the ides</pre><pre>   <strong>User</strong>::create($request-&gt;all());</pre><pre>   <strong>return</strong> redirect(route(&#39;users.index&#39;))<br>            -&gt;with([&#39;message&#39;=&gt;&quot;User ({$request-&gt;fullname}) created&quot;]);</pre><pre>}</pre><p>I’ve also created a special method called collection() which returns an Illuminate\Support\Collection so that we get a collection of all the fields instead of an array by $request-&gt;all() method. We can use it in controller like this:</p><pre><strong>public </strong>function store(<strong>UserFormRequest $request</strong>)<strong><br></strong>{<br>   $request-&gt;collection()-&gt;map(function($item){<br>      ...<br>      // go nuts<br>   });<br>   // or like this for debugging</pre><pre>   $request-&gt;collection()-&gt;dd(); // thanks to the upgrades in Laravel 5.5<br>   // or<br>   $request-&gt;collection()-&gt;dump();</pre><pre>   ...</pre><p>You can install this package in your Laravel 5.5+ application:</p><pre>composer require stahiralijan/request-caster</pre><h3>Future plans</h3><p>It would be nice to have a mutator/caster that would run a user method(s) in a similar fashion before FormRequest validates the data.</p><p>I don’t know if this package will get broken in next Laravel release because of ValidatesWhenResolvedTrait, please help me by test it in older versions of Laravel.</p><p>I hope this package helps you in reducing your dev-time and increases your productivity.</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db2fcb794db9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>