<?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 Ghulam Rasool on Medium]]></title>
        <description><![CDATA[Stories by Ghulam Rasool on Medium]]></description>
        <link>https://medium.com/@imgrasool?source=rss-78d4b6d78850------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9_dx3coL6zWbsfN2lCKWqg.jpeg</url>
            <title>Stories by Ghulam Rasool on Medium</title>
            <link>https://medium.com/@imgrasool?source=rss-78d4b6d78850------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 01:59:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@imgrasool/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[Typical design patterns for Laravel application development]]></title>
            <link>https://medium.com/@imgrasool/typical-design-patterns-for-laravel-application-development-b97f1ee5fd6b?source=rss-78d4b6d78850------2</link>
            <guid isPermaLink="false">https://medium.com/p/b97f1ee5fd6b</guid>
            <category><![CDATA[principles]]></category>
            <category><![CDATA[principles-of-design]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[Ghulam Rasool]]></dc:creator>
            <pubDate>Mon, 10 Jul 2023 12:11:55 GMT</pubDate>
            <atom:updated>2023-07-10T12:13:05.408Z</atom:updated>
            <content:encoded><![CDATA[<p>Are you looking for a way to make your Laravel (or any kinda) application more organized and maintainable? Then design patterns are just what you need! Design patterns are reusable solutions to common programming problems, and Laravel makes it easy to implement them in your application.<br> <br> Let’s take a look at some of the most popular design patterns used in Laravel, and how you can use them in your own projects:</p><h3><strong>Factory Pattern:</strong></h3><p>The factory pattern is used to build objects without showing the client the creation mechanism. When using Laravel, you can utilize the factory pattern to generate new objects with random data. For instance, you might develop a class called “<a href="https://github.com/imgrasooldev/laravel-rest-api/blob/main/database/factories/UserFactory.php"><strong>UserFactory</strong></a>” that generates brand-new user objects with arbitrary names and email addresses.</p><pre>&lt;?php<br><br>namespace Database\Factories;<br><br>use Illuminate\Database\Eloquent\Factories\Factory;<br>use Illuminate\Support\Str;<br><br>/**<br> * @extends \Illuminate\Database\Eloquent\Factories\Factory&lt;\App\Models\User&gt;<br> */<br>class UserFactory extends Factory<br>{<br>    /**<br>     * Define the model&#39;s default state.<br>     *<br>     * @return array&lt;string, mixed&gt;<br>     */<br>    public function definition(): array<br>    {<br>        return [<br>            &#39;name&#39; =&gt; fake()-&gt;name(),<br>            &#39;email&#39; =&gt; fake()-&gt;unique()-&gt;safeEmail(),<br>            &#39;email_verified_at&#39; =&gt; now(),<br>            &#39;password&#39; =&gt; bcrypt(&#39;password&#39;),<br>            &#39;remember_token&#39; =&gt; Str::random(10),<br>        ];<br>    }<br><br>    /**<br>     * Indicate that the model&#39;s email address should be unverified.<br>     */<br>    public function unverified(): static<br>    {<br>        return $this-&gt;state(fn (array $attributes) =&gt; [<br>            &#39;email_verified_at&#39; =&gt; null,<br>        ]);<br>    }<br>}</pre><h3><strong>Singleton Pattern:</strong></h3><p>To make sure that just one instance of a class is produced and used throughout the programme, utilise the singleton approach. When managing resources like database connections that shouldn’t be duplicated, Laravel’s singleton paradigm may be used. For instance, the singleton pattern may be used to guarantee that only one instance of a “Mailer” class, which delivers emails, is produced.</p><pre>namespace App\Mail;<br><br>use Illuminate\Mail\Mailable;<br>use Illuminate\Bus\Queueable;<br>use Illuminate\Queue\SerializesModels;<br>use Illuminate\Contracts\Queue\ShouldQueue;<br><br>class SingletonMailer extends Mailable<br>{<br>    use Queueable, SerializesModels;<br><br>    private static $instance;<br><br>    private $data;<br><br>    private function __construct() {<br>    }<br><br>    public static function getInstance() {<br>        if (null === static::$instance) {<br>            static::$instance = new static();<br>        }<br><br>        return static::$instance;<br>    }<br><br>    public function setData($data) {<br>        $this-&gt;data = $data;<br>        return $this;<br>    }<br><br>    public function build() {<br>        return $this-&gt;view(&#39;emails.example&#39;)<br>                    -&gt;with([<br>                        &#39;data&#39; =&gt; $this-&gt;data,<br>                    ]);<br>    }<br>}</pre><pre>use App\Mail\SingletonMailer;<br>use Illuminate\Support\Facades\Mail;<br><br>$singletonMailer = SingletonMailer::getInstance();<br>$singletonMailer-&gt;setData([&#39;test&#39; =&gt; &#39;data&#39;]);<br>Mail::to(&#39;test@example.com&#39;)-&gt;send($singletonMailer);</pre><h3><strong>Repository Pattern:</strong></h3><p>Repository design: This design is used to decouple the application logic from the database layer. With Laravel, you can leverage the repository pattern to change database implementations more easily without changing the application logic. A “<a href="https://github.com/imgrasooldev/repository-pattern-in-laravel/tree/main/app/Repositories/CustomerRepository">CustomerRepository</a>” class, for instance, can be created to handle database activities on a “Product” model.</p><pre>&lt;?php<br><br>namespace App\Interfaces;<br><br>interface CustomerRepositoryInterface<br>{<br>    public function all();<br><br>    public function find($id);<br><br>    public function create(array $data);<br><br>    // ... Any other methods you need<br>}</pre><pre>&lt;?php<br><br>namespace App\Repositories;<br><br>use App\Interfaces\CustomerRepositoryInterface;<br>use App\Customer;<br><br>class CustomerRepository implements CustomerRepositoryInterface<br>{<br>    protected $model;<br><br>    public function __construct(User $model)<br>    {<br>        $this-&gt;model = $model;<br>    }<br><br>    public function all()<br>    {<br>        return $this-&gt;model-&gt;all();<br>    }<br><br>    public function find($id)<br>    {<br>        return $this-&gt;model-&gt;find($id);<br>    }<br><br>    public function create(array $data)<br>    {<br>        return $this-&gt;model-&gt;create($data);<br>    }<br><br>    // ... Implement any other methods you have defined<br>}</pre><h3><strong>Observer Pattern:</strong></h3><p>The observer pattern is used to set off events when specific activities take place. When particular model events take place, you may take extra actions using Laravel’s observer approach. For instance, you might develop a class called “<a href="https://github.com/imgrasooldev/laravel-rest-api/blob/main/app/Observers/Api/V1/CustomerObserver.php">CustomerObserver</a>” that sends out events (delete customer’s invoices ) whenever a “Customer” model is deleted.</p><pre>&lt;?php<br><br>namespace App\Observers\Api\V1;<br><br>use App\Models\Customer;<br><br>class CustomerObserver<br>{<br>    /**<br>     * Handle the Customer &quot;created&quot; event.<br>     */<br>    public function created(Customer $customer): void<br>    {<br>        //<br>    }<br><br>    /**<br>     * Handle the Customer &quot;updated&quot; event.<br>     */<br>    public function updated(Customer $customer): void<br>    {<br>        //<br>    }<br><br>    /**<br>     * Handle the Customer &quot;deleted&quot; event.<br>     */<br>    public function deleted(Customer $customer): void<br>    {<br>        $customer-&gt;invoices()-&gt;delete();<br>    }<br><br>    /**<br>     * Handle the Customer &quot;restored&quot; event.<br>     */<br>    public function restored(Customer $customer): void<br>    {<br>        //<br>    }<br><br>    /**<br>     * Handle the Customer &quot;force deleted&quot; event.<br>     */<br>    public function forceDeleted(Customer $customer): void<br>    {<br>        //<br>    }<br>}</pre><p>Your Laravel application may become more organized, manageable, and adaptable by incorporating design patterns.</p><p>Do you have any knowledge of Laravel’s design patterns? Please do follow me.</p><h4><strong>👋 Hi I am Ghulam Rasool<br> 🥑 Full Stack PHP Developer<br> 🔰 learning AI</strong></h4><h3><strong>I’m open to part-time freelancing work for people as well as full-time employment with businesses who use remote employees.</strong></h3><p>Github: <a href="https://tinyurl.com/yy93vuhs">https://tinyurl.com/yy93vuhs</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b97f1ee5fd6b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Important factors, when tuning SQL query performance]]></title>
            <link>https://medium.com/@imgrasool/important-factors-when-tuning-sql-query-performance-74ff75fa04c5?source=rss-78d4b6d78850------2</link>
            <guid isPermaLink="false">https://medium.com/p/74ff75fa04c5</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[query]]></category>
            <category><![CDATA[optimization]]></category>
            <dc:creator><![CDATA[Ghulam Rasool]]></dc:creator>
            <pubDate>Mon, 10 Jul 2023 11:22:09 GMT</pubDate>
            <atom:updated>2023-07-10T11:22:09.138Z</atom:updated>
            <content:encoded><![CDATA[<p>To optimize your SQL queries, you need to consider several factors, such as the specific language or database system you use, the structure of your data, and your particular use case.</p><p>Here are some suggestions that are broad and may be used in a variety of circumstances:</p><h3><strong>Use indexes:</strong></h3><p>To speed up data retrieval: Indexes can help a lot. The insertion of data is slowed down by them, despite the fact that they speed up data retrieval. For this reason, it’s crucial to utilize them sparingly, especially on columns that you regularly query.</p><h3><strong>Limit of Retrieval</strong>:</h3><p>Bring only the information you require. To precisely define the columns you want, use the SELECT query. Your query will run slower if you fetch extra data.</p><h3><strong>Avoid Starting Predicates with Wildcards:</strong></h3><p>Starting predicates with wildcards (%string, for example) causes a full scan of the indexed column, which significantly reduces speed. Try to stay away from it.</p><h3><strong>Write Simple questions:</strong></h3><p>Attempt to keep your questions simple, while it might not always be practicable. Complex queries tend to be slower since they are more difficult for the query optimizer to optimize.</p><h3><strong>Avoid using OR statements</strong>:</h3><p>Since they can also result in entire table scans. Replace them, if feasible, with UNION or UNION ALL.</p><h3><strong>Use Joins Properly:</strong></h3><p>Using joins is a need when working with relational databases. But not every join is the same. Typically, INNER JOINS are quicker than OUTER JOINS.</p><h3><strong>Analyze Your Query:</strong></h3><p>To learn how your query is being processed, use the EXPLAIN command (if it’s available in your database system).</p><h3><strong>Regularly Update Statistics of the Database:</strong></h3><p>Database statistics that are routinely updated are used by the query optimizer to determine the optimum query plan. The optimizer can make better judgements if they are current.</p><p>Even once your queries have been optimized, it is still crucial to regularly check their performance. The expansion of the database or modifications in usage patterns may affect how efficient a query is.</p><p>github: <a href="https://github.com/imgrasooldev/">https://github.com/imgrasooldev/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74ff75fa04c5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Eloquent 3N Relationships: Understanding and Implementation in Laravel]]></title>
            <link>https://medium.com/@imgrasool/eloquent-3n-relationships-understanding-and-implementation-in-laravel-2ea4d3eca223?source=rss-78d4b6d78850------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ea4d3eca223</guid>
            <category><![CDATA[relationships]]></category>
            <category><![CDATA[eloquent]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Ghulam Rasool]]></dc:creator>
            <pubDate>Tue, 04 Jul 2023 09:29:22 GMT</pubDate>
            <atom:updated>2023-07-04T09:30:33.004Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Eloquent ORM</strong> (Object Relational Mapping), a feature of Laravel, offers a remarkably simple-to-use and practical manner of communicating with your database.</p><p>It maintains the full capability of SQL beneath the hood while incorporating all the challenges of managing data relationships. The underutilised but potent 3N relationship is one of these relationships. We’ll go into further detail about what it represents and how to use it in your Laravel application.</p><h3><strong>A 3N Relationship:</strong></h3><p>What Is It? It’s less typical to discuss the phrase “3N” in Eloquent relationships because it’s not a standard term. The term “complex multi-table relationship” in the context of Laravel may refer to a relationship that is difficult to categorise using the traditional one-to-one, one-to-many, or many-to-many relationships.</p><p>Three models, each connected to the others in a certain fashion, could be said to be in a “3N” relationship. It might be thought of as having three tables: Table A and Table B are related one to many times, while Table C is related one to many times to Table A. In essence, this establishes a one-to-many relationship through Table B from Table A to Table C.</p><h3><strong>Definition of a 3N Relationship</strong></h3><p>Let’s assume a real-world example where we have three models: Country, State, and City to demonstrate a 3N relationship in Laravel. Every state in a nation has a large number of cities. We might describe this as a 3N relationship if we wanted to retrieve all cities for a particular nation.</p><p>Let’s define the connections between these models first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GzF8HIX_y2k0MEd2ncvWLA.png" /></figure><p>A State belongs to a Country, has many Cities, and a City belongs to a State under this situation.</p><p>There is no direct relationship between a country and its cities, therefore if we wanted to get all the cities in that country, we couldn’t do it directly. We can create a hasManyThrough relationship at this point.</p><h3><strong>The Country model says:</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q_RxCBB0XUSoJH76kFKLag.png" /></figure><p>Accessing distant relations through an intermediary relation is made simple by the hasManyThrough relationship. For instance, through an intermediary State model, a Country model may include multiple City models.</p><h3><strong>Data Retrieval for 3N Relationships</strong></h3><p>You can now use: to retrieve cities related to a country.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*autEm3TY7WLOorDgw-9i-w.png" /></figure><p>You will then be presented with a selection of City models that are specific to the states of the chosen nation.</p><h3><strong>Conclusion</strong></h3><p>Although working with database relationships is made exceedingly simple by Eloquent, it’s still vital to comprehend what these connections are and how to use them in your Laravel apps. Although a “3N” connection isn’t a term commonly used in Laravel, being familiar with it might help you model and access more complicated data relationships in your applications more efficiently.</p><p>Always try to keep your connections as straightforward as you can, and reserve the use of more complicated relationships like “3N” for special circumstances. Always check that your database and relationship structures meet the requirements of your application and facilitate development rather than complicate it.</p><p>about me: <a href="https://github.com/imgrasooldev">https://github.com/imgrasooldev</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ea4d3eca223" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Key Areas of Knowledge for Laravel Developers: A Comprehensive Guide]]></title>
            <link>https://medium.com/@imgrasool/key-areas-of-knowledge-for-laravel-developers-a-comprehensive-guide-4c62634d03d4?source=rss-78d4b6d78850------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c62634d03d4</guid>
            <category><![CDATA[laravel-development]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[php-developers]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[laravel-10]]></category>
            <dc:creator><![CDATA[Ghulam Rasool]]></dc:creator>
            <pubDate>Tue, 13 Jun 2023 04:52:54 GMT</pubDate>
            <atom:updated>2023-06-13T05:54:46.457Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*6jZWQuvTyL_EsbsWiIRzzQ.png" /></figure><p>As a Laravel developer, having a strong understanding of key concepts and topics is crucial for efficient and effective web development. In this comprehensive guide, we will explore the essential areas of knowledge that every Laravel developer should be familiar with.</p><p><strong>PHP Fundamentals:<br></strong>Laravel is built on PHP, so a solid understanding of PHP is essential. Make sure you are well-versed in PHP syntax, object-oriented programming (OOP) concepts, and commonly used PHP functions and features.</p><p><strong>Model-View-Controller (MVC) Architecture:<br></strong>Laravel follows the MVC architectural pattern. It is important to grasp the fundamental principles of MVC and how Laravel implements them. Familiarize yourself with creating models, views, and controllers, and understanding the flow of data between them.</p><p><strong>Routing in Laravel:<br></strong>Laravel provides a powerful routing system that allows you to define routes and map them to specific controller actions. Learn how to define routes, handle different HTTP methods, and work with route parameters effectively.</p><p><strong>Eloquent ORM:<br></strong>Laravel’s Eloquent ORM simplifies database interactions by providing an expressive and intuitive way to work with databases. Gain proficiency in defining models, establishing relationships between models, and performing common database operations using Eloquent.</p><p><strong>Blade Templating Engine:<br></strong>Blade is Laravel’s default templating engine, which enables you to build dynamic and reusable views. Master Blade syntax, including directives, conditionals, loops, and template inheritance, to create efficient and flexible views.</p><p><strong>Authentication and Authorization:<br></strong>Laravel offers built-in mechanisms for user authentication and authorization. Learn how to implement user registration, login, password resets, and how to protect routes and actions based on user roles and permissions.</p><p><strong>Middleware:<br></strong>Middleware in Laravel allows you to filter and modify HTTP requests and responses. Understand how to create and use middleware to handle tasks such as authentication, validation, and request modification.</p><p><strong>Caching and Performance Optimization:<br></strong>Laravel provides various caching mechanisms to improve application performance. Explore techniques such as Redis or Memcached to optimize database queries and enhance your application’s speed and efficiency.</p><p><strong>Testing Laravel Applications:<br></strong>Laravel comes with robust testing tools. Learn how to write unit tests, integration tests, and functional tests using Laravel’s testing framework to ensure the quality and reliability of your code.</p><p><strong>Deployment and Server Management:<br></strong>While not specific to Laravel, understanding deployment processes and server management is crucial. Familiarize yourself with tools like Git, SSH, Nginx, AWS and server monitoring to successfully deploy and maintain Laravel applications.</p><p>By gaining expertise in these key areas, you’ll be well-equipped to tackle Laravel development projects with confidence and efficiency. Remember to explore the Laravel documentation and engage with the Laravel community to stay updated and continuously enhance your skills.</p><p>Note: This article is written to provide general guidance and is not an exhaustive list of all topics related to Laravel development.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c62634d03d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>