<?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 AakritiCodes on Medium]]></title>
        <description><![CDATA[Stories by AakritiCodes on Medium]]></description>
        <link>https://medium.com/@aakriticodes?source=rss-090a743d7871------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by AakritiCodes on Medium</title>
            <link>https://medium.com/@aakriticodes?source=rss-090a743d7871------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 22:49:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aakriticodes/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[JavaScript ES6 Features]]></title>
            <link>https://medium.com/@aakriticodes/javascript-es6-features-you-should-know-99afd06fd7fe?source=rss-090a743d7871------2</link>
            <guid isPermaLink="false">https://medium.com/p/99afd06fd7fe</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[javascript-es6]]></category>
            <dc:creator><![CDATA[AakritiCodes]]></dc:creator>
            <pubDate>Thu, 26 Mar 2026 10:11:21 GMT</pubDate>
            <atom:updated>2026-03-28T00:07:18.989Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey there! If you’re learning JavaScript, ES6 (ECMAScript 2015) introduced some powerful features that make your code cleaner, shorter, and easier to read. Let’s explore them step by step.</p><h3>1. Variables and Functions</h3><p>With ES6, we use let and const instead of var for better scope control.</p><pre>const name = &quot;John&quot;;</pre><pre>// Traditional function<br>function sum(x, y) {<br>  return x + y;<br>}</pre><pre>// Arrow function (ES6)<br>const sumArrow = (x, y) =&gt; x + y;</pre><p>👉 Arrow functions make code shorter and more readable.</p><h3>2. Object &amp; Array Destructuring</h3><p>Destructuring allows you to extract values easily from objects and iterables (like arrays or strings).</p><pre>const user = { name: &quot;John&quot;, age: 20 };<br>const { name, age } = user;</pre><pre>const address = [&quot;Kathmandu&quot;, &quot;Bagmati&quot;];<br>const [city, province] = address;</pre><p>👉 This works with <strong>any iterable</strong>, not just arrays.</p><h3>3. Array Methods + ES6 Power</h3><p>JavaScript already had powerful array methods like map, filter, and sort (introduced before ES6).<br>But ES6 makes them more powerful and cleaner with arrow functions.</p><pre>const numbers = [1, 2, 3, 4, 5];</pre><pre>const doubled = numbers.map(n =&gt; n * 2); <br>const even = numbers.filter(n =&gt; n % 2 === 0);<br>const sorted = numbers.sort((a, b) =&gt; b - a);</pre><p>👉 ES6 didn’t introduce these methods, but made them easier to use.</p><h3>4. Template Literals</h3><p>No more messy string concatenation with +.</p><pre>const sentence = `Hello! My name is ${name} and I am ${age} years old. <br>I live in ${city}, District ${province} Province.`;</pre><p>👉 Cleaner, readable, and supports multi-line strings.</p><h3>5. Spread Operator</h3><p>The spread operator (...) helps copy or merge arrays and objects easily.</p><pre>const arr1 = [1, 2];<br>const arr2 = [...arr1, 3, 4];</pre><pre>const userCopy = { ...user, country: &quot;Nepal&quot; };</pre><p>👉 Very useful for immutability and modern development.</p><h3>Final Thoughts</h3><p>Using ES6 features, your JavaScript code becomes:</p><ul><li>Cleaner</li><li>Shorter</li><li>Easier to maintain</li></ul><p>ES6 is not just about new features — it’s about writing <strong>better JavaScript</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99afd06fd7fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel API Using Passport]]></title>
            <link>https://medium.com/@aakriticodes/laravel-api-using-passport-be73c3d6cf59?source=rss-090a743d7871------2</link>
            <guid isPermaLink="false">https://medium.com/p/be73c3d6cf59</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[api-development]]></category>
            <category><![CDATA[passport-api]]></category>
            <dc:creator><![CDATA[AakritiCodes]]></dc:creator>
            <pubDate>Tue, 13 Jan 2026 11:55:31 GMT</pubDate>
            <atom:updated>2026-01-13T11:55:31.346Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>From Scratch to Production-Ready Authentication (Register, Login, Protected Routes &amp; Logout)</strong></p><p>Authentication is a core requirement for modern APIs. Laravel Passport provides a complete OAuth2 implementation that makes securing APIs simple and reliable.</p><p>In this guide, we’ll build a <strong>fully functional Laravel API authentication system using Passport</strong>, starting from a fresh project and ending with secure protected routes and logout functionality.</p><h3>Step 1: Create a Fresh Laravel Project</h3><pre>composer create-project laravel/laravel passport-api<br>cd passport-api</pre><p>Configure your database in the .env file before proceeding.</p><h3>Step 2: Install Laravel Passport</h3><p>Install Passport via Composer:</p><pre>composer require laravel/passport</pre><p>Run migrations and install Passport:</p><pre>php artisan migrate<br>php artisan passport:install</pre><p>This command:</p><ul><li>Generates OAuth encryption keys</li><li>Creates default OAuth clients</li></ul><h3>Fix: Personal Access Client Not Found</h3><p>If you encounter this error, run:</p><pre>php artisan passport:client --personal</pre><h3>Step 3: Configure Authentication Guard</h3><p>Open config/auth.php and configure the API guard to use Passport:</p><pre>&#39;guards&#39; =&gt; [<br>    &#39;web&#39; =&gt; [<br>        &#39;driver&#39; =&gt; &#39;session&#39;,<br>        &#39;provider&#39; =&gt; &#39;users&#39;,<br>    ],</pre><pre>    &#39;api&#39; =&gt; [<br>        &#39;driver&#39; =&gt; &#39;passport&#39;,<br>        &#39;provider&#39; =&gt; &#39;users&#39;,<br>    ],<br>],</pre><pre>&#39;providers&#39; =&gt; [<br>    &#39;users&#39; =&gt; [<br>        &#39;driver&#39; =&gt; &#39;eloquent&#39;,<br>        &#39;model&#39; =&gt; App\Models\User::class,<br>    ],<br>],</pre><p>The api guard now uses Passport for authentication.</p><h3>Step 4: Add HasApiTokens Trait</h3><p>Edit app/Models/User.php:</p><pre>use Laravel\Passport\HasApiTokens;</pre><pre>class User extends Authenticatable<br>{<br>    use HasApiTokens, Notifiable, SoftDeletes;<br>}</pre><p>This enables access token creation and validation.</p><h3>Step 5: Create AuthResource</h3><p>Resources help maintain clean and consistent API responses.</p><pre>php artisan make:resource AuthResource</pre><p>app/Http/Resources/AuthResource.php:</p><pre>namespace App\Http\Resources;</pre><pre>use Illuminate\Http\Resources\Json\JsonResource;</pre><pre>class AuthResource extends JsonResource<br>{<br>    public function toArray($request)<br>    {<br>        return [<br>            &#39;id&#39;         =&gt; $this-&gt;id,<br>            &#39;name&#39;       =&gt; $this-&gt;name,<br>            &#39;email&#39;      =&gt; $this-&gt;email,<br>            &#39;created_at&#39; =&gt; $this-&gt;created_at-&gt;toDateTimeString(),<br>        ];<br>    }<br>}</pre><h3>Step 6: Create UserAuthController</h3><p>Generate the controller:</p><pre>php artisan make:controller Api/UserAuthController</pre><p>app/Http/Controllers/Api/UserAuthController.php:</p><pre>namespace App\Http\Controllers\Api;</pre><pre>use App\Http\Controllers\Controller;<br>use App\Http\Resources\AuthResource;<br>use App\Models\User;<br>use Illuminate\Http\Request;<br>use Illuminate\Support\Facades\Hash;</pre><pre>class UserAuthController extends Controller<br>{<br>    public function register(Request $request)<br>    {<br>        $data = $request-&gt;validate([<br>            &#39;name&#39;     =&gt; &#39;required|string|max:255&#39;,<br>            &#39;email&#39;    =&gt; &#39;required|email|unique:users,email&#39;,<br>            &#39;password&#39; =&gt; &#39;required|min:6&#39;,<br>        ]);</pre><pre>        $user = User::create([<br>            &#39;name&#39;     =&gt; $data[&#39;name&#39;],<br>            &#39;email&#39;    =&gt; $data[&#39;email&#39;],<br>            &#39;password&#39; =&gt; Hash::make($data[&#39;password&#39;]),<br>        ]);</pre><pre>        $token = $user-&gt;createToken(&#39;user_token&#39;)-&gt;accessToken;</pre><pre>        return response()-&gt;json([<br>            &#39;message&#39; =&gt; &#39;User registered successfully&#39;,<br>            &#39;user&#39;    =&gt; new AuthResource($user),<br>            &#39;token&#39;   =&gt; $token,<br>        ], 201);<br>    }</pre><pre>    public function login(Request $request)<br>    {<br>        $data = $request-&gt;validate([<br>            &#39;email&#39;    =&gt; &#39;required|email&#39;,<br>            &#39;password&#39; =&gt; &#39;required&#39;,<br>        ]);</pre><pre>        $user = User::where(&#39;email&#39;, $data[&#39;email&#39;])-&gt;first();</pre><pre>        if (!$user || !Hash::check($data[&#39;password&#39;], $user-&gt;password)) {<br>            return response()-&gt;json([&#39;message&#39; =&gt; &#39;Invalid credentials&#39;], 401);<br>        }</pre><pre>        $token = $user-&gt;createToken(&#39;user_token&#39;)-&gt;accessToken;</pre><pre>        return response()-&gt;json([<br>            &#39;message&#39; =&gt; &#39;Login successful&#39;,<br>            &#39;user&#39;    =&gt; new AuthResource($user),<br>            &#39;token&#39;   =&gt; $token,<br>        ]);<br>    }</pre><pre>    public function logout(Request $request)<br>    {<br>        $request-&gt;user()-&gt;tokens()-&gt;delete();</pre><pre>        return response()-&gt;json([<br>            &#39;message&#39; =&gt; &#39;Logged out successfully&#39;,<br>        ]);<br>    }</pre><pre>    public function user(Request $request)<br>    {<br>        return response()-&gt;json(<br>            new AuthResource($request-&gt;user())<br>        );<br>    }<br>}</pre><h3>Step 7: Define API Routes</h3><p>Edit routes/api.php:</p><pre>use App\Http\Controllers\Api\UserAuthController;<br>use Illuminate\Support\Facades\Route;</pre><pre>Route::post(&#39;/register&#39;, [UserAuthController::class, &#39;register&#39;]);<br>Route::post(&#39;/login&#39;, [UserAuthController::class, &#39;login&#39;]);</pre><pre>Route::middleware(&#39;auth:api&#39;)-&gt;group(function () {<br>    Route::get(&#39;/user&#39;, [UserAuthController::class, &#39;user&#39;]);<br>    Route::post(&#39;/logout&#39;, [UserAuthController::class, &#39;logout&#39;]);<br>});</pre><h3>Step 8: Test the API with Postman</h3><h3>Register User</h3><p><strong>POST</strong> /api/register</p><pre>{<br>  &quot;name&quot;: &quot;Test User&quot;,<br>  &quot;email&quot;: &quot;test@example.com&quot;,<br>  &quot;password&quot;: &quot;password123&quot;<br>}</pre><h3>Login User</h3><p><strong>POST</strong> /api/login</p><pre>{<br>  &quot;email&quot;: &quot;test@example.com&quot;,<br>  &quot;password&quot;: &quot;password123&quot;<br>}</pre><h3>Get Authenticated User</h3><p><strong>GET</strong> /api/user</p><p><strong>Header:</strong></p><pre>Authorization: Bearer &lt;token&gt;</pre><h3>Logout User</h3><p><strong>POST</strong> /api/logout</p><p><strong>Header:</strong></p><pre>Authorization: Bearer &lt;token&gt;</pre><h3>Step 9: Optional — Revoke Only Current Token</h3><pre>$request-&gt;user()-&gt;currentAccessToken()-&gt;delete();</pre><p>Useful when users are logged in on multiple devices.</p><h3>Best Practices</h3><ul><li>Use <strong>POST</strong> for login and logout</li><li>Always send token via Authorization: Bearer</li><li>Hash passwords before storing</li><li>Protect routes using auth:api</li><li>Use HTTPS in production</li><li>For SPA/mobile apps, consider Passport Password Grant or Laravel Sanctum</li></ul><h3>Conclusion</h3><p>You’ve successfully built a <strong>secure, production-ready Laravel API authentication system using Passport</strong>.</p><p>This setup is ideal for:</p><ul><li>REST APIs</li><li>Mobile applications</li><li>Third-party integrations</li></ul><p>If you found this helpful, feel free to share or bookmark it for future reference 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be73c3d6cf59" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Safely Rename Your Laravel Project]]></title>
            <link>https://medium.com/@aakriticodes/how-to-safely-rename-your-laravel-project-2437e98408a4?source=rss-090a743d7871------2</link>
            <guid isPermaLink="false">https://medium.com/p/2437e98408a4</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[rename]]></category>
            <category><![CDATA[rename-laravel-projects]]></category>
            <dc:creator><![CDATA[AakritiCodes]]></dc:creator>
            <pubDate>Mon, 05 Jan 2026 01:15:17 GMT</pubDate>
            <atom:updated>2026-01-05T01:15:17.476Z</atom:updated>
            <content:encoded><![CDATA[<p>Laravel is flexible, and sometimes you might want to <strong>rename your project</strong> — maybe for clarity, or just because the original name doesn’t fit anymore. The good news? <strong>It’s safe</strong> if done properly. Here’s a simple guide.</p><h3>Step 1: Rename the Project Folder</h3><p>The easiest part: just rename your project folder on your system.<br> Example:</p><pre>task-manager → task-management-system</pre><blockquote><em>Laravel doesn’t rely on the folder name, so this is mostly safe.</em></blockquote><p>⚠️ Things to check:</p><ul><li>.env file’s APP_NAME</li><li>Local server path (XAMPP, Valet, etc.)</li><li>Git repository (if using)</li></ul><h3>Step 2: Update Laravel Configurations</h3><p>Open .env and update the project name:</p><pre>APP_NAME=&quot;Task Management System&quot;</pre><p>Optional: check config/app.php:</p><pre>&#39;name&#39; =&gt; env(&#39;APP_NAME&#39;, &#39;Laravel&#39;),</pre><p>Then clear the configuration cache:</p><pre>php artisan config:clear</pre><h3>Step 3: Composer Autoload (if namespaces changed)</h3><p>If you changed <strong>namespaces</strong> inside the app/ folder:</p><pre>composer dump-autoload</pre><p>This ensures Laravel knows the updated structure.</p><h3>Step 4: Update GitHub Repo (if pushed)</h3><ol><li>Rename the repository on GitHub: <strong>Settings → Rename</strong></li><li>Update local repository URL:</li></ol><pre>git remote set-url origin https://github.com/username/new-repo-name.git</pre><ol><li>Verify:</li></ol><pre>git remote -</pre><h3>Important Notes</h3><ul><li>✅ Local / learning project → folder rename is usually enough</li><li>✅ Deployed / professional project → update .env, configs, and Git carefully</li><li>❌ Don’t change namespaces or paths randomly without updating autoload</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2437e98408a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel Interview Questions — Quick Notes for Developers ]]></title>
            <link>https://medium.com/@aakriticodes/laravel-interview-questions-quick-notes-for-developers-74541f0f5b5e?source=rss-090a743d7871------2</link>
            <guid isPermaLink="false">https://medium.com/p/74541f0f5b5e</guid>
            <category><![CDATA[webdevelopmentinternship]]></category>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[AakritiCodes]]></dc:creator>
            <pubDate>Tue, 30 Dec 2025 08:00:08 GMT</pubDate>
            <atom:updated>2025-12-30T08:04:12.503Z</atom:updated>
            <content:encoded><![CDATA[<h3>Laravel Interview Questions — Quick Notes for Developers 🚀</h3><p>This guide covers commonly asked <strong>Laravel, PHP, SQL, JavaScript, and OOP questions</strong> in a <strong>short and simple format</strong>, ideal for intern and junior developer interviews.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/0*89Mx6O5dyZftwjPK.png" /></figure><h3>1. What projects have you done?</h3><p>I have worked on several Laravel projects including:</p><ul><li>News Portal</li><li>Task Management System</li><li>Blog System</li><li>E-commerce Website</li></ul><p>These projects helped me understand <strong>Laravel MVC, authentication, CRUD operations, database relationships, and real-world backend development</strong>.</p><h3>2. What is Composer?</h3><p><strong>Composer</strong> is a dependency manager for PHP.<br>It is used to install Laravel, manage packages, and handle autoloading of classes.</p><p><strong>Example:</strong></p><pre>composer install<br>composer require package-name</pre><h3>3. What is Artisan?</h3><p><strong>Artisan</strong> is Laravel’s command-line interface (CLI).<br>It automates common tasks like creating files, running migrations, clearing cache, and starting the server.</p><p><strong>Common Artisan commands:</strong></p><pre>php artisan serve<br>php artisan make:controller UserController<br>php artisan make:model Post -m<br>php artisan migrate<br>php artisan cache:clear</pre><h3>4. How do you create email functionality in Laravel?</h3><p>Laravel uses <strong>Mail classes, Blade templates, and mail drivers (SMTP, Gmail, Mailtrap)</strong>.</p><p><strong>Steps:</strong></p><ol><li>Create a Mail class: php artisan make:mail WelcomeMail</li><li>Design the email using Blade</li><li>Configure mail settings in .env</li><li>Send mail: Mail::to($user-&gt;email)-&gt;send(new WelcomeMail());</li></ol><h3>5. How do you create a migration without CLI?</h3><p>You can manually create a migration file in database/migrations/ and define up() and down() methods.</p><blockquote><em>Using Artisan (</em><em>php artisan make:migration) is recommended for consistency.</em></blockquote><h3>6. Laravel Architecture</h3><p>Laravel follows the <strong>MVC architecture</strong>:</p><ul><li><strong>Model</strong> — database logic</li><li><strong>View</strong> — UI (Blade templates)</li><li><strong>Controller</strong> — request &amp; response</li></ul><p>It also uses <strong>middleware, routing, and service containers</strong>.</p><h3>7. Laravel Request Life Cycle</h3><ol><li>Request enters public/index.php</li><li>Goes to HTTP Kernel</li><li>Middleware handles the request</li><li>Route matches the request</li><li>Controller executes</li><li>Response returned to the browser</li></ol><h3>8. Laravel Default Port</h3><p>Laravel runs on <strong>port 8000</strong> by default:</p><pre>php artisan serve</pre><h3>9. What is ORM?</h3><p><strong>ORM (Object Relational Mapping)</strong> allows developers to interact with the database using objects instead of writing raw SQL queries.</p><h3>10. What is Eloquent?</h3><p><strong>Eloquent</strong> is Laravel’s built-in ORM.<br>It provides <strong>clean syntax for database operations</strong> and supports relationships between models.</p><h3>11. Difference between Raw SQL, Query Builder, and ORM</h3><p><strong>Raw SQL</strong></p><ul><li>Written manually</li><li>Fast but hard to maintain</li><li>Not reusable</li><li>No model or relationship support</li></ul><p><strong>Query Builder</strong></p><ul><li>Programmatic SQL</li><li>Cleaner and readable</li><li>Reusable queries</li><li>Limited relationship support</li></ul><p><strong>ORM (Eloquent)</strong></p><ul><li>Object-based using models</li><li>Most readable and maintainable</li><li>Highly reusable</li><li>Supports full model relationships</li></ul><h3>12. SQL Query — Find users with name “ram”</h3><pre>SELECT * FROM users WHERE name LIKE &#39;%ram%&#39;;</pre><h3>13. Difference between var and const in JavaScript</h3><p><strong>var</strong></p><ul><li>Function scoped</li><li>Can be redeclared</li><li>Can be updated</li></ul><p><strong>const</strong></p><ul><li>Block scoped</li><li>Cannot be redeclared</li><li>Cannot be updated</li></ul><h3>14. OOP Features</h3><ul><li>Encapsulation</li><li>Inheritance</li><li>Polymorphism</li><li>Abstraction</li></ul><h3>15. Inheritance — Types</h3><ul><li>Single inheritance</li><li>Multilevel inheritance</li><li>Hierarchical inheritance</li></ul><h3>16. Does PHP support multiple inheritance?</h3><p>❌ PHP does not support multiple inheritance using classes.<br>✅ It can be implemented using <strong>Traits</strong>.</p><h3>17. What is Polymorphism?</h3><p>Polymorphism allows the same method name to behave differently depending on the object or class (method overriding, interface implementation).</p><h3>18. What is SQL Injection?</h3><p>SQL Injection is an attack where malicious SQL code is injected through user input to manipulate the database.</p><p><strong>Example (unsafe):</strong></p><pre>SELECT * FROM users WHERE email = &#39;$email&#39; AND password = &#39;$password&#39;;</pre><p><strong>Safe way (Laravel Eloquent):</strong></p><pre>User::where(&#39;email&#39;, $email)-&gt;first();</pre><h3>19. Why do we use CSRF?</h3><p>CSRF protects the application from unauthorized requests. Laravel uses <strong>CSRF tokens</strong> to validate forms.</p><p><strong>Example:</strong></p><pre>&lt;form method=&quot;POST&quot;&gt;<br>    @csrf<br>    &lt;button&gt;Submit&lt;/button&gt;<br>&lt;/form&gt;</pre><h3>20. What is Laravel Sanctum?</h3><p>Sanctum is a <strong>lightweight authentication system</strong> for APIs, SPAs, and mobile apps using <strong>token-based authentication</strong>.</p><p><strong>Example:</strong></p><pre>$token = $user-&gt;createToken(&#39;api-token&#39;)-&gt;plainTextToken;</pre><h3>21. Difference between Sanctum and Passport</h3><p><strong>Sanctum</strong> — Simple token-based auth, best for SPAs and mobile apps.<br><strong>Passport</strong> — Full OAuth2, best for large APIs or third-party integrations.</p><h3>22. How do you create API authentication in Laravel?</h3><ol><li>Create API routes in routes/api.php</li><li>Authenticate users and generate tokens</li><li>Protect routes using middleware</li></ol><p><strong>Example:</strong></p><pre>Route::middleware(&#39;auth:sanctum&#39;)-&gt;get(&#39;/user&#39;, function () {<br>    return auth()-&gt;user();<br>});</pre><h3>23. What is Middleware in Laravel?</h3><p>Middleware acts as a <strong>filter between the request and response</strong>.<br>It handles tasks like authentication, authorization, logging, or request modification.</p><p><strong>Example:</strong></p><pre>Route::get(&#39;/dashboard&#39;, function () {<br>    return view(&#39;dashboard&#39;);<br>})-&gt;middleware(&#39;auth&#39;);</pre><blockquote><em>Only authenticated users can access </em><em>/dashboard.</em></blockquote><p>This flow covers <strong>core Laravel concepts, security, API authentication, OOP, SQL, and JS basics</strong>, making it <strong>perfect for a developer interview prep</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74541f0f5b5e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Junior Laravel Developer Interview Guide — Everything You Must Know]]></title>
            <link>https://medium.com/@aakriticodes/junior-laravel-developer-interview-guide-everything-you-must-know-a97f6843cb10?source=rss-090a743d7871------2</link>
            <guid isPermaLink="false">https://medium.com/p/a97f6843cb10</guid>
            <category><![CDATA[junior-developer]]></category>
            <category><![CDATA[laravel-developer]]></category>
            <category><![CDATA[laravel-interview]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[backend]]></category>
            <dc:creator><![CDATA[AakritiCodes]]></dc:creator>
            <pubDate>Sun, 16 Nov 2025 10:02:31 GMT</pubDate>
            <atom:updated>2025-11-23T07:17:08.584Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Junior Laravel Developer Interview Guide — Everything You Must Know</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*_7NGkkaO90rf2XHhOvpgTA.png" /><figcaption>Junior Laravel Developer Interview Guide</figcaption></figure><p>Laravel is one of the most popular PHP frameworks, known for its elegant syntax, developer-friendly approach, and powerful ecosystem. If you’re preparing for a <strong>junior Laravel developer interview</strong>, this guide covers the most commonly asked questions — explained simply and clearly.</p><h3>1. How does Laravel work? (MVC Framework)</h3><p>Laravel works using the <strong>MVC architecture</strong>:</p><ul><li><strong>Model</strong> → Handles database operations using Eloquent ORM</li><li><strong>View</strong> → Blade templates that display UI</li><li><strong>Controller</strong> → Accepts requests, performs logic, returns responses</li></ul><p><strong>Flow:</strong> Request → Route → Controller → Model → View → Response</p><h3>2. What is Eloquent and why do we use it?</h3><p>Eloquent is Laravel’s <strong>ORM</strong> that helps you interact with the database using PHP syntax instead of SQL.</p><p><strong>Reasons to use Eloquent:</strong></p><ul><li>Very readable</li><li>Handles relationships</li><li>Easy query building</li><li>Prevents SQL injection</li><li>Faster development</li></ul><h3>3. What are the types of relationships in Laravel?</h3><p>Laravel supports:</p><ul><li><strong>One-to-One</strong></li><li><strong>One-to-Many</strong></li><li><strong>Many-to-Many</strong></li><li><strong>Polymorphic relationships</strong></li></ul><h3>4. What is a polymorphic relationship?</h3><p>A polymorphic relationship allows <strong>multiple models</strong> to share a <strong>single relationship</strong>.</p><p>Example:<br> Comments can belong to both Posts <em>and</em> Videos.</p><p>Uses fields:</p><ul><li>commentable_id</li><li>commentable_type</li></ul><h3>5. How do you represent a simple User and Posts relationship?</h3><p><strong>User model:</strong></p><pre>public function posts() {<br>    return $this-&gt;hasMany(Post::class);<br>}</pre><p><strong>Post model:</strong></p><pre>public function user() {<br>    return $this-&gt;belongsTo(User::class);<br>}</pre><p>Meaning: <strong>One user → many posts</strong></p><h3>6. What does User::with(&#39;posts&#39;)-&gt;get() do?</h3><p>It performs <strong>eager loading</strong>:</p><ul><li>Loads all users</li><li>Loads all posts belonging to each user</li><li>Reduces extra queries</li><li>Improves performance</li></ul><h3>7. What is the N+1 query problem?</h3><p>It happens when:</p><ul><li>You load <strong>N records</strong></li><li>Then run <strong>1 extra query for each record</strong></li></ul><p>Example (bad/lazy loading):</p><pre>$users = User::all();<br>foreach ($users as $user) {<br>    echo $user-&gt;posts;<br>}</pre><p><strong>Solution:</strong></p><pre>User::with(&#39;posts&#39;)-&gt;get();</pre><h3>8. What is middleware in Laravel?</h3><p>Middleware is a <strong>filter</strong> that checks or modifies requests <strong>before</strong> they reach the controller.</p><p>Used for:</p><ul><li>Authentication</li><li>Role checking</li><li>Logging</li><li>Maintenance mode</li><li>CORS handling</li></ul><h3>9. How do you create middleware?</h3><h3>Create:</h3><pre>php artisan make:middleware CheckAdmin</pre><h3>Inside middleware:</h3><pre>if (auth()-&gt;user()-&gt;role !== &#39;admin&#39;) {<br>    abort(403);<br>}<br>return $next($request);</pre><h3>Apply to routes:</h3><pre>Route::middleware(&#39;admin&#39;)-&gt;group(function () {<br>    // admin-only routes<br>});</pre><h3>10. What is authentication in Laravel?</h3><p>Authentication determines <strong>who the user is</strong>.</p><p>Laravel uses:</p><ul><li>Breeze</li><li>Jetstream</li><li>Sanctum</li><li>Laravel UI</li></ul><h3>11. What is authorization in Laravel?</h3><p>Authorization determines <strong>what the user can do</strong>.</p><p>Laravel uses:</p><ul><li>Gates</li><li>Policies</li><li>Middleware (admin/user roles)</li></ul><h3>12. How do you allow only authenticated users to access a page?</h3><p>Use the <strong>auth</strong> middleware:</p><pre>Route::get(&#39;/dashboard&#39;, function () {<br>    return view(&#39;dashboard&#39;);<br>})-&gt;middleware(&#39;auth&#39;);</pre><p>Unauthenticated users are redirected to login.</p><h3>13. How do you handle authorization in Laravel?</h3><p>Three main ways:</p><h3>Using Gates</h3><pre>Gate::define(&#39;isAdmin&#39;, fn($user) =&gt; $user-&gt;role == &#39;admin&#39;);</pre><h3>Using Policies</h3><p>Used for model-based permissions (PostPolicy, UserPolicy)</p><h3>Using Middleware</h3><pre>Route::middleware(&#39;admin&#39;)-&gt;group(...);</pre><h3>14. What is the Laravel request lifecycle?</h3><p>Simple version:</p><ol><li>Request enters through public/index.php</li><li>Goes to <strong>HTTP Kernel</strong></li><li>Global middleware executes</li><li>Route service providers load</li><li>Route is matched</li><li>Controller executes</li><li>Response is returned</li></ol><h3>15. What is a queue in Laravel?</h3><p>Queues allow heavy tasks to run <strong>in background</strong>, not during the main request.</p><p>Used for:</p><ul><li>Emails</li><li>Notifications</li><li>Reports</li><li>Image processing</li></ul><h3>16. How does a queue work in Laravel?</h3><p>You run the queue worker:</p><pre>php artisan queue:work</pre><p>or one-time:</p><pre>php artisan queue:work --once</pre><p>Jobs stored in: database, Redis, SQS, etc.<br> Laravel processes them asynchronously.</p><h3>17. Why do we use queues?</h3><ul><li>Improve performance</li><li>Prevent slow page loads</li><li>Reduce server load</li><li>Handle high-traffic operations</li><li>Process tasks in the background</li></ul><p>Example: sending 1000 emails without blocking the web request.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a97f6843cb10" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel Private, Protected, and Public Methods Explained (with Example)]]></title>
            <link>https://medium.com/@aakriticodes/laravel-private-protected-and-public-methods-explained-with-example-d278abb8932d?source=rss-090a743d7871------2</link>
            <guid isPermaLink="false">https://medium.com/p/d278abb8932d</guid>
            <category><![CDATA[livewire]]></category>
            <category><![CDATA[access-modifier]]></category>
            <category><![CDATA[public-private-protected]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[private]]></category>
            <dc:creator><![CDATA[AakritiCodes]]></dc:creator>
            <pubDate>Thu, 30 Oct 2025 09:04:24 GMT</pubDate>
            <atom:updated>2025-10-30T09:04:46.828Z</atom:updated>
            <content:encoded><![CDATA[<p>When working with Laravel models, you’ll often declare methods as <strong>private</strong>, <strong>protected</strong>, or <strong>public</strong>. But what’s the difference? Let’s break it down with examples.</p><h3>Private</h3><p>A private method can only be accessed <strong>inside the same class</strong>. Child classes cannot call it.</p><pre>class BlogPost extends Model<br>{<br>    private function formatTitle($title)<br>    {<br>        return strtoupper($title);<br>    }</pre><pre>    public function showTitle($title)<br>    {<br>        return $this-&gt;formatTitle($title); // ✅ Works<br>    }<br>}</pre><pre>class SubPost extends BlogPost<br>{<br>    public function test()<br>    {<br>        return $this-&gt;formatTitle(&#39;test&#39;); // ❌ Error<br>    }<br>}</pre><h3>Protected</h3><p>A protected method can be accessed <strong>within the class and by child classes</strong>, but not from outside.</p><pre>class BlogPost extends Model<br>{<br>    protected function generateSlug($title)<br>    {<br>        return Str::slug($title);<br>    }<br>}</pre><pre>class SubPost extends BlogPost<br>{<br>    public function testSlug()<br>    {<br>        return $this-&gt;generateSlug(&#39;Hello World&#39;); // ✅ Works<br>    }<br>}</pre><h3>Public</h3><p>A public method can be accessed <strong>anywhere</strong> — inside or outside the class.</p><pre>class BlogPost extends Model<br>{<br>    public function getAllPosts()<br>    {<br>        return BlogPost::all();<br>    }<br>}</pre><pre>$post = new BlogPost();<br>$post-&gt;getAllPosts(); // ✅ Works</pre><h3>Tips for Laravel Models</h3><ul><li>Use <strong>protected</strong> for helper methods (e.g., booted(), generateSlug()).</li><li>Use <strong>public</strong> for relationships or methods called from controllers.</li><li>Avoid <strong>private</strong> unless the method is strictly for internal logic.</li></ul><p><strong>Takeaway:</strong> Understanding access levels helps you write <strong>secure, maintainable, and reusable Laravel code</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d278abb8932d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Blade, API & apiResource in Laravel]]></title>
            <link>https://medium.com/@aakriticodes/blade-api-apiresource-in-laravel-f94ea6dae5be?source=rss-090a743d7871------2</link>
            <guid isPermaLink="false">https://medium.com/p/f94ea6dae5be</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[api-resources]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[blade]]></category>
            <category><![CDATA[laravel-rest-api]]></category>
            <dc:creator><![CDATA[AakritiCodes]]></dc:creator>
            <pubDate>Tue, 28 Oct 2025 15:11:53 GMT</pubDate>
            <atom:updated>2025-10-28T15:11:53.765Z</atom:updated>
            <content:encoded><![CDATA[<p>Laravel gives us multiple ways to show data — using <strong>Blade</strong>, <strong>APIs</strong>, and <strong>Resources</strong>.<br> Understanding how they connect helps you build apps that serve both <strong>your users</strong> and <strong>other applications</strong> efficiently.</p><p>Let’s break it down 👇</p><p><strong>Blade — The User Interface Side</strong></p><p><strong>Blade</strong> is Laravel’s built-in and powerful template engine.<br> It’s used to display <strong>HTML pages</strong> to end-users — perfect for dashboards, simple websites, and admin panels.</p><h3>🧩 Example: Showing a List of Users</h3><pre>// routes/web.php<br>Route::get(&#39;/users&#39;, [UserController::class, &#39;index&#39;]);</pre><pre>// app/Http/Controllers/UserController.php<br>class UserController extends Controller<br>{<br>    public function index()<br>    {<br>        $users = User::all();<br>        // Returns an HTML view file<br>        return view(&#39;users.index&#39;, compact(&#39;users&#39;));<br>    }<br>}</pre><pre>&lt;!-- resources/views/users/index.blade.php --&gt;<br>&lt;h2&gt;Users&lt;/h2&gt;<br>&lt;ul&gt;<br>    @foreach($users as $user)<br>        &lt;li&gt;{{ $user-&gt;name }}&lt;/li&gt;<br>    @endforeach<br>&lt;/ul&gt;</pre><p>✅ Renders <strong>HTML</strong> for browsers<br> ✅ Used in <strong>web.php</strong> routes<br> ✅ Perfect for <strong>UI-based</strong> apps where backend handles all rendering</p><h3>⚙️ API — The Machine Data Side</h3><p><strong>APIs (Application Programming Interfaces)</strong> send <strong>raw data</strong> (usually JSON), not HTML.<br> They’re used by <strong>mobile apps</strong> or <strong>frontend frameworks</strong> like React, Vue, or Flutter.</p><h3>🧩 Example: Sending User Data as JSON</h3><pre>// routes/api.php<br>Route::get(&#39;/users&#39;, [UserApiController::class, &#39;index&#39;]);</pre><pre>// app/Http/Controllers/Api/UserApiController.php<br>class UserApiController extends Controller<br>{<br>    public function index()<br>    {<br>        // Returns data as JSON<br>        return response()-&gt;json(User::all());<br>    }<br>}</pre><p>✅ Returns <strong>JSON</strong>, not HTML<br> ✅ Used for <strong>machine-to-machine</strong> communication<br> ✅ No Blade view needed</p><h3>⚡ apiResource — Fast RESTful API Routing</h3><p>Instead of writing all CRUD routes manually, Laravel gives you a shortcut.</p><h3>🧩 Example</h3><pre>// routes/api.php<br>Route::apiResource(&#39;tasks&#39;, TaskController::class);</pre><p>This <strong>one line</strong> replaces 5 manual routes 👇</p><p>Method URL Action Purpose GET /api/tasks index Get all tasks POST /api/tasks store Create new task GET /api/tasks/{id} show Get a single task PUT /api/tasks/{id} update Update a task DELETE /api/tasks/{id} destroy Delete a task</p><p>✅ Cleaner and faster route setup<br> ✅ Only generates JSON routes (no create/edit pages)</p><h3>🧩 resource vs apiResource</h3><p>Feature resource() apiResource() File web.php api.php Returns Views (HTML) JSON (API) Includes create &amp; edit routes ✅ Yes ❌ No Best For Web (Blade) Apps APIs / Mobile</p><h3>📦 API Resources &amp; Resource Collections</h3><p>By default, APIs send <strong>all model fields</strong> — even sensitive ones.<br> To control what data is exposed, Laravel offers <strong>API Resources</strong> and <strong>Resource Collections</strong>.</p><h3>1️⃣ Create a Resource</h3><pre>php artisan make:resource TaskResource</pre><h3>2️⃣ Define the JSON Structure</h3><pre>// app/Http/Resources/TaskResource.php<br>public function toArray($request)<br>{<br>    return [<br>        &#39;id&#39; =&gt; $this-&gt;id,<br>        &#39;title&#39; =&gt; $this-&gt;title,<br>        &#39;status&#39; =&gt; $this-&gt;status,<br>        // Exclude sensitive fields<br>    ];<br>}</pre><h3>3️⃣ Use in Controller</h3><pre>// Single model<br>public function show(Task $task)<br>{<br>    return new TaskResource($task);<br>}</pre><pre>// Collection of models<br>public function index()<br>{<br>    return TaskResource::collection(Task::all());<br>}</pre><h3>Example Output</h3><pre>{<br>    &quot;id&quot;: 1,<br>    &quot;title&quot;: &quot;Complete Laravel project&quot;,<br>    &quot;status&quot;: &quot;active&quot;<br>}</pre><p>✅ Controls what leaves your API<br> ✅ Keeps output clean and consistent<br> ✅ Essential for professional-scale apps</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f94ea6dae5be" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Model vs Controller Methods in Laravel (with Examples)]]></title>
            <link>https://medium.com/@aakriticodes/model-vs-controller-methods-in-laravel-with-examples-294138561f6d?source=rss-090a743d7871------2</link>
            <guid isPermaLink="false">https://medium.com/p/294138561f6d</guid>
            <category><![CDATA[deve]]></category>
            <category><![CDATA[web]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[laravel-development]]></category>
            <dc:creator><![CDATA[AakritiCodes]]></dc:creator>
            <pubDate>Tue, 28 Oct 2025 01:03:56 GMT</pubDate>
            <atom:updated>2025-10-28T01:03:56.920Z</atom:updated>
            <content:encoded><![CDATA[<p>When learning Laravel, it’s important to know the difference between <strong>model</strong> and <strong>controller</strong> methods.<br> They work together — but each has a clear role. 👇</p><h3>⚙️ Controller Methods — Handle Requests</h3><p>Controllers respond to routes and manage requests from web or API.<br> They call models to get or store data, then return responses.</p><pre>class UserController extends Controller<br>{<br>    public function index()<br>    {<br>        $users = User::all();<br>        return view(&#39;users.index&#39;, compact(&#39;users&#39;));<br>    }</pre><pre>    public function store(Request $request)<br>    {<br>        User::create($request-&gt;all());<br>        return back()-&gt;with(&#39;success&#39;, &#39;User created!&#39;);<br>    }<br>}</pre><p>✅ Used in routes (web.php, api.php)<br> ✅ Handle web &amp; API requests</p><h3>🧩 Model Methods — Handle Data</h3><p>Models represent database tables and hold logic for fetching or formatting data.</p><pre>class User extends Model<br>{<br>    public function fullName()<br>    {<br>        return $this-&gt;first_name . &#39; &#39; . $this-&gt;last_name;<br>    }</pre><pre>    public function scopeActive($query)<br>    {<br>        return $query-&gt;where(&#39;status&#39;, &#39;active&#39;);<br>    }<br>}</pre><p>✅ Define relationships &amp; helpers<br> ✅ Keep database logic separate from controllers</p><h3>🔄 Working Together</h3><pre>class TaskController extends Controller<br>{<br>    public function index()<br>    {<br>        $tasks = Task::active()-&gt;get();<br>        return view(&#39;tasks.index&#39;, compact(&#39;tasks&#39;));<br>    }<br>}</pre><p>Model handles <strong>data</strong>,<br> Controller handles <strong>requests</strong> — simple and clean. 💡</p><h3>🧠 Quick Summary</h3><p>Type Purpose Example <strong>Controller</strong> Handle routes &amp; responses index(), store() <strong>Model</strong> Handle data logic scopeActive(), fullName()</p><p>💬 Keep controllers light and push logic to models.<br> That’s how you write clean Laravel code. 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=294138561f6d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Public, Private & Constructor Methods in Laravel Controllers (with Examples)]]></title>
            <link>https://medium.com/@aakriticodes/understanding-public-private-constructor-methods-in-laravel-controllers-with-examples-dcd5ccfc0c13?source=rss-090a743d7871------2</link>
            <guid isPermaLink="false">https://medium.com/p/dcd5ccfc0c13</guid>
            <dc:creator><![CDATA[AakritiCodes]]></dc:creator>
            <pubDate>Tue, 28 Oct 2025 00:46:18 GMT</pubDate>
            <atom:updated>2025-10-28T00:47:07.525Z</atom:updated>
            <content:encoded><![CDATA[<p>When building Laravel applications, controllers are where most of your logic lives.<br> But understanding the difference between <strong>public</strong>, <strong>private</strong>, and <strong>constructor</strong> methods helps you write cleaner, more secure, and maintainable code.</p><p>Let’s go step by step 👇</p><h3>🔹Public Methods — Handle Routes (Web &amp; API)</h3><p>Public methods are the <strong>entry points</strong> of your controller.<br> They’re the ones Laravel can access through <strong>web.php</strong> or <strong>api.php</strong> routes.</p><p>In simple terms:</p><blockquote><em>Only </em><strong><em>public methods</em></strong><em> can be called from your browser, Postman, or frontend apps.</em></blockquote><h3>Example</h3><pre>// routes/web.php<br>Route::get(&#39;/users&#39;, [UserController::class, &#39;index&#39;]);</pre><pre>// routes/api.php<br>Route::get(&#39;/api/users&#39;, [UserController::class, &#39;getUsers&#39;]);</pre><pre>// app/Http/Controllers/UserController.php<br>class UserController extends Controller<br>{<br>    // Web route method<br>    public function index()<br>    {<br>        $users = User::all();<br>        return view(&#39;users.index&#39;, compact(&#39;users&#39;));<br>    }</pre><pre>    // API route method<br>    public function getUsers()<br>    {<br>        return response()-&gt;json(User::all());<br>    }<br>}</pre><p>✅ Both of these methods are <strong>public</strong> — which means they can be accessed via:</p><ul><li>https://yourapp.com/users (web)</li><li>https://yourapp.com/api/users (API)</li></ul><p>📌 <strong>Key Rule:</strong><br> Laravel can only route requests to <strong>public</strong> methods — private or protected ones will never be accessible directly.</p><h3>🔹 Private &amp; Protected Methods — Internal Logic</h3><p>Private and protected methods are for <strong>internal use only</strong>.<br> They help keep your logic clean, reusable, and hidden from external access.</p><p>Use them for helper logic that supports your public methods.</p><h3>Example</h3><pre>class UserController extends Controller<br>{<br>    public function index()<br>    {<br>        $users = $this-&gt;getActiveUsers();<br>        return view(&#39;users.index&#39;, compact(&#39;users&#39;));<br>    }</pre><pre>    // Internal helper method<br>    private function getActiveUsers()<br>    {<br>        return User::where(&#39;status&#39;, &#39;active&#39;)-&gt;get();<br>    }<br>}</pre><p>🔒 This getActiveUsers() method:</p><ul><li>Cannot be accessed from a route.</li><li>Can only be called <em>inside</em> the controller.</li><li>Keeps your code modular and protected.</li></ul><h3>🔹 Constructor (__construct) — Runs Automatically</h3><p>The <strong>constructor</strong> method is called <strong>whenever the controller is instantiated</strong>.<br> It’s commonly used to apply <strong>middleware</strong> or set up <strong>dependencies</strong>.</p><h3>Example: Applying Middleware</h3><pre>class UserController extends Controller<br>{<br>    public function __construct()<br>    {<br>        $this-&gt;middleware(&#39;auth&#39;);<br>    }</pre><pre>    public function index()<br>    {<br>        return view(&#39;users.index&#39;);<br>    }<br>}</pre><p>Now every route that uses this controller will automatically require authentication.</p><h3>Example: Dependency Injection</h3><pre>class TaskController extends Controller<br>{<br>    protected $taskService;</pre><pre>    public function __construct(TaskService $taskService)<br>    {<br>        $this-&gt;taskService = $taskService;<br>    }</pre><pre>    public function show($id)<br>    {<br>        return $this-&gt;taskService-&gt;find($id);<br>    }<br>}</pre><p>This keeps your controller focused on handling requests — not business logic.</p><h3>🧩 Quick Summary</h3><p>Method Type Purpose Access Example Use <strong>Public</strong> Handles requests Web &amp; API routes index(), store(), update() <strong>Private</strong> Internal helper logic Only inside class getActiveUsers() <strong>Protected</strong> Shared with subclasses Inherited controllers formatData() <strong>Constructor</strong> Setup &amp; middleware Auto-called __construct()</p><h3>✅ Best Practice Tips</h3><ul><li>Always keep route methods <strong>public</strong></li><li>Move repeated logic to <strong>private</strong> methods</li><li>Use <strong>constructor</strong> for middleware and dependency injection</li><li>Avoid writing heavy logic directly inside controllers</li></ul><h3>🧠 Final Thought</h3><p>A well-structured Laravel controller separates concerns clearly:<br> <strong>Public methods handle requests</strong>,<br> <strong>Private methods handle logic</strong>,<br> <strong>Constructor handles setup</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dcd5ccfc0c13" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Add Email Verification in Laravel 12]]></title>
            <link>https://medium.com/@aakriticodes/how-to-add-email-verification-in-laravel-12-e239d2202665?source=rss-090a743d7871------2</link>
            <guid isPermaLink="false">https://medium.com/p/e239d2202665</guid>
            <category><![CDATA[develop]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[nepal]]></category>
            <category><![CDATA[laravel-job]]></category>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[AakritiCodes]]></dc:creator>
            <pubDate>Fri, 17 Oct 2025 09:23:32 GMT</pubDate>
            <atom:updated>2025-10-17T09:25:54.210Z</atom:updated>
            <content:encoded><![CDATA[<h3>1. Install Laravel 12 &amp; Breeze</h3><h3>Start by installing <strong>Laravel</strong> and <strong>Breeze</strong> for simple authentication scaffolding:</h3><pre>composer create-project --prefer-dist laravel/laravel laravel-breeze<br>cd laravel-breeze<br>composer require laravel/breeze --dev<br>php artisan breeze:install<br>npm install &amp;&amp; npm run dev<br>php artisan migrate</pre><h4>2. Enable Email Verification</h4><p>Laravel makes it easy to add email verification by implementing the MustVerifyEmail contract.</p><ol><li><strong>Modify the User Model</strong>: Add the MustVerifyEmail contract to the User model.</li></ol><pre>// app/Models/User.php</pre><pre>namespace App\Models;</pre><pre>use Illuminate\Contracts\Auth\MustVerifyEmail;<br>use Illuminate\Foundation\Auth\User as Authenticatable;</pre><pre>class User extends Authenticatable implements MustVerifyEmail<br>{<br>    // No changes needed here apart from implementing MustVerifyEmail<br>}</pre><p>This ensures Laravel will handle email verification automatically.</p><h4>3. Protect Routes with Email Verification</h4><p>Laravel Breeze automatically includes the necessary routes for email verification. To protect routes, use the verified middleware.</p><p>For example, to protect a POST route:</p><pre>// routes/web.php</pre><pre>use App\Http\Controllers\PostController;</pre><pre>Route::middleware([&#39;auth&#39;, &#39;verified&#39;])-&gt;group(function () {<br>    Route::post(&#39;/submit-post&#39;, [PostController::class, &#39;store&#39;]);<br>});</pre><p>This ensures only verified users can access the /submit-post route.</p><h4>4. Customize the Verification Email (Optional)</h4><p>If you want to customize the verification email, create a custom notification:</p><pre>php artisan make:notification CustomVerifyEmail</pre><p>In CustomVerifyEmail.php, modify the email content:</p><pre>// app/Notifications/CustomVerifyEmail.php</pre><pre>namespace App\Notifications;</pre><pre>use Illuminate\Auth\Notifications\VerifyEmail;<br>use Illuminate\Notifications\Messages\MailMessage;</pre><pre>class CustomVerifyEmail extends VerifyEmail<br>{<br>    public function toMail($notifiable)<br>    {<br>        return (new MailMessage)<br>            -&gt;subject(&#39;Verify Your Email Address&#39;)<br>            -&gt;line(&#39;Click the button below to verify your email address.&#39;)<br>            -&gt;action(&#39;Verify Email&#39;, url(https://medium.com/$this-&gt;verificationUrl($notifiable)));<br>    }<br>}</pre><p>In the <strong>User model</strong>, use your custom notification:</p><pre>// app/Models/User.php</pre><pre>public function sendEmailVerificationNotification()<br>{<br>    $this-&gt;notify(new CustomVerifyEmail());<br>}</pre><h4>5. Verify User Email</h4><p>Once users register, they’ll receive an email with a link to verify their email address. Laravel handles the rest, including sending the email and redirecting users once verified.</p><h3>Conclusion</h3><p>With these steps, you’ve added <strong>email verification</strong> to your Laravel 12 app using <strong>Breeze</strong>. By default, Laravel will send a verification email and prevent unverified users from accessing protected routes.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e239d2202665" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>