<?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 Iqbal Ramadhani on Medium]]></title>
        <description><![CDATA[Stories by Iqbal Ramadhani on Medium]]></description>
        <link>https://medium.com/@iqbal.ramadhani55?source=rss-5c824c364f6c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*DE3L5Ar_i0EgKNgH</url>
            <title>Stories by Iqbal Ramadhani on Medium</title>
            <link>https://medium.com/@iqbal.ramadhani55?source=rss-5c824c364f6c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 18:01:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@iqbal.ramadhani55/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[Session Flash in Laravel]]></title>
            <link>https://medium.com/@iqbal.ramadhani55/session-flash-in-laravel-b7b62cb7074b?source=rss-5c824c364f6c------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7b62cb7074b</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[sessions]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[flash]]></category>
            <dc:creator><![CDATA[Iqbal Ramadhani]]></dc:creator>
            <pubDate>Tue, 05 Mar 2024 06:28:40 GMT</pubDate>
            <atom:updated>2024-03-05T06:28:40.345Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FaIh0w97WkEQTNZ0BbMlkQ.png" /></figure><p>Session flash messages are stored in the session for the next request only. Once the next request is made, the flash data is removed from the session. This makes flash messages ideal for displaying one-time notifications to users, such as success messages after a form submission or error messages when validation fails.</p><h4>Implementation Steps</h4><p>Let’s dive into implementing session flash notifications in Laravel:</p><p><strong>Step 1 : Set Flash Message<br></strong>In your controller method, after performing an action that requires notification, you can set a flash message using the with method:</p><pre>public function store(Request $request)<br>{<br>    // Your validation and processing logic<br>    // Example: Store a success message<br>    return redirect()-&gt;route(&#39;dashboard&#39;)-&gt;with(&#39;success&#39;, &#39;Item successfully created!&#39;);<br>}</pre><p><strong>Step 2 : Display Flash Message<br></strong>In your Blade template, you can check for the existence of flash messages and display them accordingly:</p><pre>@if (session(&#39;success&#39;))<br>    &lt;div class=&quot;alert alert-success&quot;&gt;<br>        {{ session(&#39;success&#39;) }}<br>    &lt;/div&gt;<br>@endif</pre><p><strong>Step 3 : Styles and Customization<br></strong>You can customize the appearance of your Flash messages by adding CSS styles to your template or by using pre-defined CSS frameworks like Bootstrap.</p><h4>Handling Different Notification Types</h4><p>You can create flash messages for various notification types such as success, error, warning, and info. Simply use different keys in the with method when setting flash messages in your controller:</p><pre>return redirect()-&gt;route(&#39;dashboard&#39;)-&gt;with(&#39;error&#39;, &#39;An error occurred while processing your request.&#39;);</pre><p>Then, in your Blade template, you can display these messages accordingly:</p><pre>@if (session(&#39;error&#39;))<br>    &lt;div class=&quot;alert alert-danger&quot;&gt;<br>        {{ session(&#39;error&#39;) }}<br>    &lt;/div&gt;<br>@endif</pre><p>Session flash messages provide a simple yet effective way to implement notifications in Laravel applications. By leveraging Laravel’s built-in session handling, developers can quickly provide feedback to users without the need for complex configurations. Whether it’s success messages, error notifications, or other types of feedback, session flash messages offer a seamless user experience. Experiment with different notification types and styles to enhance the usability of your Laravel applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7b62cb7074b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Session in Laravel]]></title>
            <link>https://medium.com/@iqbal.ramadhani55/session-in-laravel-287b06af9e24?source=rss-5c824c364f6c------2</link>
            <guid isPermaLink="false">https://medium.com/p/287b06af9e24</guid>
            <category><![CDATA[sessions]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Iqbal Ramadhani]]></dc:creator>
            <pubDate>Wed, 28 Feb 2024 04:19:47 GMT</pubDate>
            <atom:updated>2024-02-28T04:19:47.462Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vvFU8H5Dan1OJea4zd0ngg.png" /></figure><p>In Laravel, sessions are used to store and retrieve data on a per-user basis, allowing you to persist data across multiple requests. Laravel provides a simple and expressive way to work with sessions. Here’s a step-by-step guide on how to implement sessions in Laravel:</p><p><strong>1. Configuration<br></strong>Make sure your config/session.php configuration file is properly set up. You can configure the session driver, lifetime, and other options here.</p><p><strong>2. Storing Data in Session<br></strong>You can use the session helper or the Session facade to store data in the session. Here&#39;s an example:</p><pre>// Using the session helper<br>session([&#39;key&#39; =&gt; &#39;value&#39;]);<br><br>// Using the Session facade<br>use Illuminate\Support\Facades\Session;<br><br>Session::put(&#39;key&#39;, &#39;value&#39;);</pre><p><strong>3. Retrieving Data from Session<br></strong>Retrieve data from the session using the session helper or Session facade:</p><pre>// Using the session helper<br>$value = session(&#39;key&#39;);<br><br>// Using the Session facade<br>use Illuminate\Support\Facades\Session;<br>$value = Session::get(&#39;key&#39;);</pre><p><strong>4. Flash Data<br></strong>Flash data is used to store data in the session only for the next request. This is useful for displaying messages after a form submission. You can use the flash method:</p><pre>// Using the session helper<br>session()-&gt;flash(&#39;key&#39;, &#39;value&#39;);<br><br>// Using the Session facade<br>use Illuminate\Support\Facades\Session;<br>Session::flash(&#39;key&#39;, &#39;value&#39;);</pre><p><strong>5. Retrieving Flash Data<br></strong>Retrieve flash data in the next request:</p><pre>// Using the session helper<br>$value = session(&#39;key&#39;);<br><br>// Using the Session facade<br>use Illuminate\Support\Facades\Session;<br>$value = Session::get(&#39;key&#39;);</pre><p><strong>6. Removing Data from Session<br></strong>To remove data from the session, you can use the forget method:</p><pre>// Using the session helper<br>session()-&gt;forget(&#39;key&#39;);<br><br>// Using the Session facade<br>use Illuminate\Support\Facades\Session;<br>Session::forget(&#39;key&#39;);</pre><p><strong>7. Destroying the Session<br></strong>To completely destroy the session, including all data and the session identifier, you can use the flush method:</p><pre>// Using the session helper<br>session()-&gt;flush();<br><br>// Using the Session facade<br>use Illuminate\Support\Facades\Session;<br>Session::flush();</pre><p><strong>8. Checking if a Key Exists in Session<br></strong>You can check if a key exists in the session using the has method:</p><pre>// Using the session helper<br>if (session()-&gt;has(&#39;key&#39;)) {<br>    // Key exists<br>}<br><br>// Using the Session facade<br>use Illuminate\Support\Facades\Session;<br>if (Session::has(&#39;key&#39;)) {<br>    // Key exists<br>}</pre><p>These are basic examples to get you started with session management in Laravel. Depending on your application, you may need to use more advanced features such as session middleware or custom session drivers. Refer to the official Laravel documentation on sessions for more details and options.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=287b06af9e24" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deleting Files in Laravel]]></title>
            <link>https://medium.com/@iqbal.ramadhani55/deleting-files-in-laravel-3aca8f5e5044?source=rss-5c824c364f6c------2</link>
            <guid isPermaLink="false">https://medium.com/p/3aca8f5e5044</guid>
            <category><![CDATA[deleted-files]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Iqbal Ramadhani]]></dc:creator>
            <pubDate>Tue, 30 Jan 2024 06:24:11 GMT</pubDate>
            <atom:updated>2024-01-30T06:24:11.205Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tNmwRv5Cu4k08JK6MnkMrg.png" /></figure><p><strong>1. Using the File Facade<br></strong>Laravel provides a convenient File facade for common file operations. To delete a file using the File facade, follow these steps:</p><pre>use Illuminate\Support\Facades\File;<br><br>$file_path = public_path(&#39;path/to/your/file.txt&#39;);<br>if (File::exists($file_path)) {<br>    File::delete($file_path);<br>    echo &#39;File deleted successfully.&#39;;<br>} else {<br>    echo &#39;File does not exist.&#39;;<br>}</pre><p>In this example, replace &#39;path/to/your/file.txt&#39; with the actual path to the file you want to delete. The File::exists method ensures that the file exists before attempting deletion.</p><p><strong>2. Using the Storage Facade<br></strong>Laravel’s Storage facade provides an abstraction layer for interacting with various filesystems, making it an excellent choice for more flexible file management. Here&#39;s an example of deleting a file using the Storage facade:</p><pre>use Illuminate\Support\Facades\Storage;<br><br>$file_path = &#39;path/to/your/file.txt&#39;;<br>if (Storage::exists($file_path)) {<br>    Storage::delete($file_path);<br>    echo &#39;File deleted successfully.&#39;;<br>} else {<br>    echo &#39;File does not exist.&#39;;<br>}</pre><p>Similar to the File facade example, replace &#39;path/to/your/file.txt&#39; with the actual path to your file. The Storage::exists method checks if the file exists before attempting deletion.</p><p><strong>3. Additional Considerations<br></strong>a. Permissions<br>Ensure that your application has the necessary file system permissions to delete files. The web server user should have write permissions in the directory where the file resides. <br>b. Error Handling<br>Implement proper error handling to deal with situations where file deletion fails. This could be due to insufficient permissions, non-existent files, or other unexpected issues.</p><p><strong>4. Deleting Multiple Files<br></strong>If you need to delete multiple files at once, you can loop through an array of file paths and delete each one individually using the chosen method. This is particularly useful when managing batches of files.</p><pre>$files_to_delete = [&#39;path/to/file1.txt&#39;, &#39;path/to/file2.txt&#39;, &#39;path/to/file3.txt&#39;];<br><br>foreach ($files_to_delete as $file_path) {<br>    if (File::exists($file_path)) {<br>        File::delete($file_path);<br>        echo &#39;File deleted successfully: &#39; . $file_path . PHP_EOL;<br>    } else {<br>        echo &#39;File does not exist: &#39; . $file_path . PHP_EOL;<br>    }<br>}</pre><p>Efficient file deletion is a crucial aspect of managing a Laravel application. Whether using the File or Storage facade, understanding the different methods available and incorporating proper error handling ensures smooth file management within your Laravel project. Choose the approach that aligns with your specific use case and project requirements for optimal file deletion functionality.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3aca8f5e5044" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Upload File in Laravel]]></title>
            <link>https://medium.com/@iqbal.ramadhani55/upload-file-in-laravel-9394efbd7867?source=rss-5c824c364f6c------2</link>
            <guid isPermaLink="false">https://medium.com/p/9394efbd7867</guid>
            <category><![CDATA[files]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[upload]]></category>
            <category><![CDATA[life]]></category>
            <dc:creator><![CDATA[Iqbal Ramadhani]]></dc:creator>
            <pubDate>Sat, 30 Dec 2023 04:01:02 GMT</pubDate>
            <atom:updated>2023-12-30T04:01:02.219Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mU2pdd3leVjnlgcFRsxx3A.png" /></figure><p>Uploading files in Laravel is a common task, and the framework provides a convenient way to handle file uploads. Here, I’ll walk you through the basic steps to create a file upload feature in a Laravel application.</p><p><strong>1. Setting Up Your Laravel Project<br></strong>Before diving into file uploads, ensure that you have a Laravel project up and running. If you don’t have one, you can create a new project using Composer:</p><pre>composer create-project --prefer-dist laravel/laravel your-project-name</pre><p><strong>2. Configuring File Uploads<br></strong>Laravel’s configuration file, config/filesystems.php, contains settings related to file uploads. Ensure that the public disk is configured correctly. The public disk is commonly used for storing publicly accessible files.</p><pre>&#39;disks&#39; =&gt; [<br>    // ...<br>    &#39;public&#39; =&gt; [<br>        &#39;driver&#39; =&gt; &#39;local&#39;,<br>        &#39;root&#39; =&gt; public_path(&#39;uploads&#39;),<br>        &#39;url&#39; =&gt; env(&#39;APP_URL&#39;).&#39;/uploads&#39;,<br>        &#39;visibility&#39; =&gt; &#39;public&#39;,<br>    ],<br>    // ...<br>],</pre><p><strong>3. Creating the Upload Controller<br></strong>Generate a controller that will handle file uploads. Run the following command in your terminal:</p><pre>php artisan make:controller FileUploadController</pre><p>Open the generated FileUploadController.php file (located in the app/Http/Controllers directory)</p><p><strong>4. Handling File Uploads in the Controller<br></strong>In your FileUploadController, implement the logic to handle file uploads. Use the store method provided by Laravel&#39;s Storage facade to move the uploaded file to the desired disk.</p><pre>use Illuminate\Support\Facades\Storage;<br><br>public function upload(Request $request)<br>{<br>    $request-&gt;validate([<br>        &#39;file&#39; =&gt; &#39;required|mimes:jpg,png,pdf|max:2048&#39;,<br>    ]);<br><br>    $file = $request-&gt;file(&#39;file&#39;);<br>    $path = $file-&gt;store(&#39;uploads&#39;, &#39;public&#39;);<br><br>    // Additional logic (e.g., storing file information in the database)<br><br>    return &quot;File uploaded successfully!&quot;;<br>}</pre><p><strong>5. Displaying Uploaded Files<br></strong>To display uploaded files, create a route and controller method to fetch and render them. Use the Storage facade to generate the public URL for the files.</p><pre>use Illuminate\Support\Facades\Storage;<br><br>public function show($filename)<br>{<br>    $url = Storage::url(https://medium.com/&quot;uploads/%7B$filename%7D&quot;);<br><br>    return view(&#39;file.show&#39;, [&#39;url&#39; =&gt; $url]);<br>}</pre><p><strong>6. Building the File Upload Form<br></strong>Create a form in your views that allows users to upload files. Ensure that the form has the enctype attribute set to multipart/form-data support file uploads:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>    &lt;title&gt;Laravel File Upload&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;form action=&quot;{{ route(&#39;upload&#39;) }}&quot; method=&quot;POST&quot; enctype=&quot;multipart/form-data&quot;&gt;<br>        @csrf<br>        &lt;input type=&quot;file&quot; name=&quot;file&quot;&gt;<br>        &lt;button type=&quot;submit&quot;&gt;Upload&lt;/button&gt;<br>    &lt;/form&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p><strong>7. Set Up Routes<br></strong>Open the routes/web.php file and add the following route:</p><pre>use App\Http\Controllers\FileUploadController;<br><br>Route::get(&#39;/&#39;, function () {<br>    return view(&#39;welcome&#39;);<br>});<br>Route::post(&#39;/upload&#39;, [FileUploadController::class, &#39;upload&#39;])-&gt;name(&#39;upload&#39;);use App\Http\Controllers\FileUploadController;</pre><p><strong>8. Validating and Securing File Uploads<br></strong>Implementing proper validation is essential to ensure that users upload only allowed file types and sizes. Use Laravel’s validation rules, as shown in the example above. Additionally, consider securing your file uploads by placing them outside the public directory or using unique filenames to prevent potential security vulnerabilities.</p><p><strong>9. Run the Application<br></strong>Start the development server:</p><pre>php artisan serve</pre><p>Visit http://127.0.0.1:8000 in your browser and try uploading a file using the form.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9394efbd7867" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hasing in Laravel]]></title>
            <link>https://systemweakness.com/hasing-in-laravel-ac9a2bb6119c?source=rss-5c824c364f6c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac9a2bb6119c</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[hashing]]></category>
            <category><![CDATA[encryption]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Iqbal Ramadhani]]></dc:creator>
            <pubDate>Tue, 19 Dec 2023 23:39:36 GMT</pubDate>
            <atom:updated>2023-12-22T17:25:45.572Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o9hbUBeSPdHXm0-mFCsxwA.png" /></figure><p>Hashing in Laravel is a crucial security feature used to protect sensitive data, particularly user passwords. It involves transforming plaintext passwords into fixed-length, non-reversible values that cannot be easily deciphered even if attackers gain access to your database.</p><p><strong>Hashing Basics in Laravel<br></strong>Laravel uses the bcrypt hashing algorithm by default. This algorithm not only securely hashes passwords but also incorporates a salt, which enhances the overall security of the hashed password. To hash a password in Laravel, you can use the bcrypt function:</p><pre>$hashedPassword = bcrypt(&#39;user_password&#39;);</pre><p><strong>Password Verification<br></strong>Laravel simplifies the process of password verification with the Hash::check method. When a user attempts to log in, you can compare the entered password with the hashed password stored in the database:</p><pre>if (Hash::check(&#39;user_entered_password&#39;, $hashedPasswordFromDatabase)) {<br>    // Passwords match<br>} else {<br>    // Passwords do not match<br>}</pre><p>This approach ensures a secure and straightforward method for validating user credentials.</p><p><strong>Hashing Options<br></strong>Laravel allows developers to customize hashing options using the Hash::make method with an array of options. One crucial option is the &#39;rounds&#39; parameter, determining the number of hashing rounds to execute. Increasing rounds enhances security by making brute-force attacks more computationally expensive:</p><pre>$hashedPassword = Hash::make(&#39;plain_password&#39;, [<br>    &#39;rounds&#39; =&gt; 12, // Number of hashing rounds<br>]);</pre><p><strong>Automatic Password Hashing in Models<br></strong>Laravel makes it convenient to automatically hash passwords when saving a model. By utilizing the saving event in the model, you can ensure that the password is hashed before persisting it in the database:</p><pre>class User extends Model<br>{<br>    protected static function boot()<br>    {<br>        parent::boot();<br><br>        static::saving(function ($user) {<br>            $user-&gt;password = bcrypt($user-&gt;password);<br>        });<br>    }<br>}</pre><p>This approach streamlines the development process and maintains the security of user passwords.</p><p><strong>Best Practices for Password Hashing</strong></p><ul><li>Always use Laravel’s built-in bcrypt for password hashing. It is a proven and secure algorithm.</li><li>Regularly update your Laravel framework to benefit from the latest security enhancements and improvements.</li><li>Choose an appropriate number of hashing rounds to balance security and performance.</li><li>Implement strong password policies to ensure that users create secure passwords.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac9a2bb6119c" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/hasing-in-laravel-ac9a2bb6119c">Hasing in Laravel</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Encrypting and Decrypting Data in Laravel]]></title>
            <link>https://medium.com/@iqbal.ramadhani55/encrypting-and-decrypting-data-in-laravel-e5cb802db370?source=rss-5c824c364f6c------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5cb802db370</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[decrypt]]></category>
            <category><![CDATA[encryption]]></category>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[Iqbal Ramadhani]]></dc:creator>
            <pubDate>Sat, 09 Dec 2023 13:20:21 GMT</pubDate>
            <atom:updated>2023-12-09T13:20:21.435Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YpykDmA1_B9U4lnMk-SdPA.png" /></figure><p>Encryption is crucial for protecting sensitive information, ensuring that it remains secure both during storage and transmission. In this article, we will explore how to leverage Laravel’s encryption capabilities to safeguard your application’s data.</p><p><strong>Encryption in Laravel:<br></strong>Laravel provides a straightforward way to encrypt data using the encrypt function. This function uses the OpenSSL library to perform the encryption, ensuring a high level of security.</p><pre>// Encrypting data<br>$originalData = &#39;Hello, world!&#39;;<br>$encryptedData = encrypt($originalData);</pre><p>The encrypt function transforms the original data into a base64-encoded, encrypted version. This is particularly useful when you need to store sensitive information in databases or transmit it securely.</p><p><strong>Decryption in Laravel:<br></strong>To retrieve the original data, Laravel offers the decrypt function. This function reverses the encryption process, decrypting the data using the appropriate encryption key.</p><pre>// Decrypting data<br>$decryptedData = decrypt($encryptedData);</pre><p>By decrypting the data, you can retrieve the original information, allowing you to use it within your application.</p><p><strong>Practical Example:<br></strong>Let’s consider a practical example within a Laravel controller:</p><pre>use Illuminate\Support\Facades\Crypt;<br><br>class EncryptionController extends Controller<br>{<br>    public function encryptAndDecrypt()<br>    {<br>        // Encrypt data<br>        $originalData = &#39;Hello, world!&#39;;<br>        $encryptedData = encrypt($originalData);<br>        // Decrypt data<br>        $decryptedData = decrypt($encryptedData);<br>        // Output results<br>        return [<br>            &#39;original_data&#39; =&gt; $originalData,<br>            &#39;encrypted_data&#39; =&gt; $encryptedData,<br>            &#39;decrypted_data&#39; =&gt; $decryptedData,<br>        ];<br>    }<br>}</pre><p>In this example, we encrypt a string and then decrypt it, showcasing the simplicity of the process.</p><p><strong>Using EncryptString and DecryptString:<br></strong>For more convenience, Laravel provides encryptString and decryptString methods via the Crypt facade.</p><pre>$encryptedString = Crypt::encryptString(&#39;Hello, world!&#39;);<br>$decryptedString = Crypt::decryptString($encryptedString);</pre><p>These methods offer a cleaner syntax, making it easier to integrate encryption and decryption directly into your code.</p><p><strong>Important Considerations:</strong></p><p><strong>Keep Encryption Key Secure:</strong> <br>Laravel relies on the APP_KEY specified in your .env file for encryption. Ensure this key is kept confidential, as anyone with access to it can decrypt the data.</p><p><strong>Version Compatibility:</strong><br>Laravel evolves, and syntax may vary between versions. Always refer to the official documentation for the Laravel version you are using.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5cb802db370" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reset Laravel Password Via Email]]></title>
            <link>https://medium.com/@iqbal.ramadhani55/reset-laravel-password-via-email-d38023cdf3d8?source=rss-5c824c364f6c------2</link>
            <guid isPermaLink="false">https://medium.com/p/d38023cdf3d8</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[passwords]]></category>
            <category><![CDATA[reset]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Iqbal Ramadhani]]></dc:creator>
            <pubDate>Wed, 06 Dec 2023 22:28:22 GMT</pubDate>
            <atom:updated>2023-12-06T22:28:22.051Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A8CBlGzIesnJAQf9_1NWLA.png" /></figure><p>In Laravel, you can implement a password reset functionality using the built-in Illuminate\Auth\Passwords\PasswordBroker class. Here&#39;s a step-by-step guide on how to implement a password reset using email in Laravel:</p><p><strong>1. Set Up the Laravel Project</strong></p><p>If you haven’t already, create a new Laravel project using the following command:</p><pre>composer create-project --prefer-dist laravel/laravel your-project-name</pre><p>Navigate to your project directory:</p><pre>cd your-project-name</pre><p><strong>2. Configure Email Settings</strong></p><p>Open the .env file and configure your mail settings. Laravel uses the MAIL_DRIVER, MAIL_HOST, MAIL_PORT, MAIL_USERNAME, and MAIL_PASSWORD variables to send emails. Choose an appropriate mail driver (e.g., SMTP) and provide the necessary credentials.</p><pre>MAIL_DRIVER=smtp<br>MAIL_HOST=your-smtp-host<br>MAIL_PORT=your-smtp-port<br>MAIL_USERNAME=your-smtp-username<br>MAIL_PASSWORD=your-smtp-password<br>MAIL_FROM_ADDRESS=your-email@example.com<br>MAIL_FROM_NAME=&quot;${APP_NAME}&quot;</pre><p><strong>3. Database Configuration</strong></p><p>Laravel uses a database table (password_resets) to store token and email information for password reset requests. To create this table, run the migration:</p><pre>php artisan migrate</pre><p><strong>4. Update User Model</strong></p><p>Ensure your User model uses the Illuminate\Notifications\Notifiable trait. This trait includes the notify method, which Laravel uses to send password reset notifications.</p><pre>use Illuminate\Notifications\Notifiable;<br><br>class User extends Authenticatable<br>{<br>    use Notifiable;<br>    // ...<br>}</pre><p><strong>5. Generate Reset Password Controllers</strong></p><p>Generate the necessary controllers for password reset functionality:</p><pre>php artisan make:controller ForgotPasswordController<br>php artisan make:controller ResetPasswordController</pre><p><strong>6. Implement ForgotPasswordController</strong></p><p>In ForgotPasswordController, use the SendsPasswordResetEmails trait:</p><pre>use Illuminate\Foundation\Auth\SendsPasswordResetEmails;<br><br>class ForgotPasswordController extends Controller<br>{<br>    use SendsPasswordResetEmails;<br>}</pre><p><strong>7. Implement ResetPasswordController</strong></p><p>In ResetPasswordController, use the ResetsPasswords trait:</p><pre>use Illuminate\Foundation\Auth\ResetsPasswords;<br><br>class ResetPasswordController extends Controller<br>{<br>    use ResetsPasswords;<br>}</pre><p><strong>8. Create Password Reset Views</strong></p><p>Create the necessary views for the password reset functionality in the resources/views/auth/passwords directory. Laravel provides default views, but you can customize them to match your application&#39;s design.</p><p><strong>9. Implement Routes</strong></p><p>Define the routes for password reset in routes/web.php:</p><pre>use App\Http\Controllers\ForgotPasswordController;<br>use App\Http\Controllers\ResetPasswordController;<br><br>Route::get(&#39;password/reset&#39;, [ForgotPasswordController::class, &#39;showLinkRequestForm&#39;])-&gt;name(&#39;password.request&#39;);<br>Route::post(&#39;password/email&#39;, [ForgotPasswordController::class, &#39;sendResetLinkEmail&#39;])-&gt;name(&#39;password.email&#39;);<br>Route::get(&#39;password/reset/{token}&#39;, [ResetPasswordController::class, &#39;showResetForm&#39;])-&gt;name(&#39;password.reset&#39;);<br>Route::post(&#39;password/reset&#39;, [ResetPasswordController::class, &#39;reset&#39;])-&gt;name(&#39;password.update&#39;);</pre><p><strong>10. Test the Password Reset Flow</strong></p><p>With everything set up, you can now test the password reset functionality by visiting the appropriate routes in your application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d38023cdf3d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Login and Register in Laravel]]></title>
            <link>https://medium.com/@iqbal.ramadhani55/login-and-register-in-laravel-628aa262b128?source=rss-5c824c364f6c------2</link>
            <guid isPermaLink="false">https://medium.com/p/628aa262b128</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[register]]></category>
            <category><![CDATA[login]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Iqbal Ramadhani]]></dc:creator>
            <pubDate>Sat, 02 Dec 2023 09:29:55 GMT</pubDate>
            <atom:updated>2023-12-02T09:29:55.996Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nHTeC82TENPIF0DNhv5Yiw.png" /></figure><p>In Laravel, you can use the built-in authentication scaffolding to quickly set up login and registration functionality. Laravel provides a command-line tool called Artisan that makes it easy to generate authentication controllers, views, and routes.</p><p><strong>Step 1: Install Laravel<br></strong>If you haven’t already installed Laravel, you can do so using Composer:</p><pre>composer create-project --prefer-dist laravel/laravel your_project_name</pre><p><strong>Step 2: Configure Database<br></strong>Update your database configuration in the .env file with your database credentials:</p><pre>DB_CONNECTION=mysql<br>DB_HOST=127.0.0.1<br>DB_PORT=3306<br>DB_DATABASE=your_database_name<br>DB_USERNAME=your_database_username<br>DB_PASSWORD=your_database_password</pre><p><strong>Step 3: Run Migrations<br></strong>Run the migrations to create the necessary tables for authentication:</p><pre>php artisan migrate</pre><p><strong>Step 4: Create Authentication Controllers<br></strong>Laravel provides artisan commands to generate authentication controllers and views. Run the following commands:</p><pre>php artisan make:auth</pre><p>This command will generate controllers, views, and routes necessary for registration and login.</p><p><strong>Step 5: Start the Development Server</strong></p><pre>php artisan serve</pre><p>Visit http://127.0.0.1:8000 in your browser, and you should see the authentication scaffolding.</p><p><strong>Step 6: Registration and Login<br></strong>Navigate to http://localhost:8000/register to access the registration page. Users can enter their information, including name, email, and password.</p><p>The login page is available at http://localhost:8000/login. Once registered, users can log in using their credentials.</p><p><strong>Step 7: Make any Adjustments (Optional)<br></strong>You can customize the authentication views or controllers as needed. The views are located in the resources/views/auth directory, and the controllers are in the app/Http/Controllers/Auth directory. For more advanced customization, you may refer to the Laravel documentation: <a href="https://laravel.com/docs/authentication">Authentication Laravel</a>.</p><p>Implementing user authentication in Laravel is a straightforward process, thanks to the built-in tools provided by the framework. By following these steps, developers can quickly set up a secure and user-friendly login and registration system for their Laravel applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=628aa262b128" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Many to Many Relations in Laravel]]></title>
            <link>https://medium.com/@iqbal.ramadhani55/many-to-many-relations-in-laravel-c3c2c5906241?source=rss-5c824c364f6c------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3c2c5906241</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[many-to-many-relationship]]></category>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[Iqbal Ramadhani]]></dc:creator>
            <pubDate>Mon, 27 Nov 2023 23:13:37 GMT</pubDate>
            <atom:updated>2023-11-27T23:13:37.715Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uDjP1iWvVmpantC0kc3y8w.png" /></figure><p>A many-to-many relationship in Laravel is a type of relationship between two database tables where each record in one table can be related to multiple records in another table, and vice versa. This type of relationship is common when dealing with complex data structures, such as students and courses, where each student can enrol in multiple courses, and each course can have multiple students.</p><p>Here’s a step-by-step guide on how to set up and use a many-to-many relationship in Laravel:</p><p><strong>1. Database Setup<br></strong>Assume you have two tables: students and courses. To establish a many-to-many relationship, you&#39;ll need a pivot table. Let&#39;s call it course_student. This table will store the relationships between students and courses.</p><pre>// Create migration for course_student pivot table<br>php artisan make:migration create_course_student_table</pre><p>In the migration file:</p><pre>Schema::create(&#39;course_student&#39;, function (Blueprint $table) {<br>    $table-&gt;id();<br>    $table-&gt;unsignedBigInteger(&#39;course_id&#39;);<br>    $table-&gt;unsignedBigInteger(&#39;student_id&#39;);<br>    $table-&gt;timestamps();<br><br>    $table-&gt;foreign(&#39;course_id&#39;)-&gt;references(&#39;id&#39;)-&gt;on(&#39;courses&#39;)-&gt;onDelete(&#39;cascade&#39;);<br>    $table-&gt;foreign(&#39;student_id&#39;)-&gt;references(&#39;id&#39;)-&gt;on(&#39;students&#39;)-&gt;onDelete(&#39;cascade&#39;);<br>});</pre><p>Run the migration:</p><pre>php artisan migrate</pre><p><strong>2. Eloquent Models<br></strong>Create Eloquent models for the Student and Course tables.</p><pre> // Student.php<br>class Student extends Model {<br>    public function courses() {<br>        return $this-&gt;belongsToMany(Course::class);<br>    }<br>}<br><br>// Course.php<br>class Course extends Model {<br>    public function students() {<br>        return $this-&gt;belongsToMany(Student::class);<br>    }<br>}</pre><p><strong>3. Usage<br></strong>Now you can easily work with the many-to-many relationship in your code:</p><pre>// Attaching a student to a course<br>$student = Student::find(1);<br>$course = Course::find(1);<br><br>$student-&gt;courses()-&gt;attach($course-&gt;id);<br><br>// Detaching a student from a course<br>$student-&gt;courses()-&gt;detach($course-&gt;id);<br><br>// Retrieving all courses for a student<br>$studentCourses = $student-&gt;courses;<br><br>// Retrieving all students for a course<br>$courseStudents = $course-&gt;students;</pre><p>By following these steps, you’ve set up a many-to-many relationship in Laravel, allowing you to easily associate and retrieve related records between the students and courses tables through the course_student pivot table.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3c2c5906241" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[One to Many Relations in Laravel]]></title>
            <link>https://medium.com/@iqbal.ramadhani55/one-to-many-relations-in-laravel-6e341ee13969?source=rss-5c824c364f6c------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e341ee13969</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[one-to-many-relationship]]></category>
            <dc:creator><![CDATA[Iqbal Ramadhani]]></dc:creator>
            <pubDate>Wed, 22 Nov 2023 15:26:38 GMT</pubDate>
            <atom:updated>2023-11-22T15:26:38.791Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*27hg4sBydWgXTXCOzadIyw.png" /></figure><p>A one-to-many relationship is a fundamental concept in relational database design where a single record in one table is associated with multiple records in another table. In the context of Laravel, this often translates to a parent model that has multiple child models.</p><p>Consider a common example: a blog application with two tables, users and posts. Each user can have multiple posts, creating a one-to-many relationship. The users table would act as the parent, and the posts table as the child, where each post belongs to a single user.</p><p>Here’s a step-by-step guide on how to set up a one-to-many relationship in Laravel:</p><h4>Example Scenario:</h4><p>Let’s say we have two tables: users and posts. Each user can have multiple posts, creating a one-to-many relationship.</p><h4><strong>Step 1: Database Setup</strong></h4><p>Ensure that your database tables are set up correctly. In this example, you might have a users table and a posts table.</p><p><strong>users table migration:</strong></p><pre>Schema::create(&#39;users&#39;, function (Blueprint $table) {<br>    $table-&gt;id();<br>    $table-&gt;string(&#39;name&#39;);<br>    // other user fields<br>    $table-&gt;timestamps();<br>});</pre><p>posts table migration:</p><pre>Schema::create(&#39;posts&#39;, function (Blueprint $table) {<br>    $table-&gt;id();<br>    $table-&gt;string(&#39;title&#39;);<br>    $table-&gt;text(&#39;content&#39;);<br>    $table-&gt;unsignedBigInteger(&#39;user_id&#39;); // Foreign key<br>    $table-&gt;timestamps();<br>    $table-&gt;foreign(&#39;user_id&#39;)-&gt;references(&#39;id&#39;)-&gt;on(&#39;users&#39;);<br>});</pre><h4>Step 2: Eloquent Models</h4><p>Create Eloquent models for both User and Post:</p><p>User Model</p><pre>// app/Models/User.php<br><br>namespace App\Models;<br>use Illuminate\Database\Eloquent\Model;<br>class User extends Model<br>{<br>    protected $fillable = [&#39;name&#39;];<br>    public function posts()<br>    {<br>        return $this-&gt;hasMany(Post::class);<br>    }<br>}</pre><p>Post Model</p><pre>// app/Models/Post.php<br>namespace App\Models;<br>use Illuminate\Database\Eloquent\Model;<br>class Post extends Model<br>{<br>    protected $fillable = [&#39;title&#39;, &#39;content&#39;];<br>    public function user()<br>    {<br>        return $this-&gt;belongsTo(User::class);<br>    }<br>}</pre><h4>Step 3: Usage</h4><p>Now you can use the relationship in your code:</p><p><strong>Creating a new post for a user</strong></p><pre>$user = User::find(1);<br><br>$post = new Post([&#39;title&#39; =&gt; &#39;New Post Title&#39;, &#39;content&#39; =&gt; &#39;Post content.&#39;]);<br>$user-&gt;posts()-&gt;save($post);</pre><p><strong>Retrieving posts for a user</strong></p><pre>$user = User::find(1);<br>$posts = $user-&gt;posts; // Collection of posts</pre><p><strong>Retrieving the user for a post:</strong></p><pre>$post = Post::find(1);<br>$user = $post-&gt;user; // User model</pre><p>This establishes a one-to-many relationship between the User and Post models, allowing you to easily work with related data in your Laravel application.</p><p>One-to-many relationships are a powerful tool in Laravel for modelling and interacting with related data. With eloquent syntax and database migrations, Laravel makes it easy for developers to implement and manage these relationships. Whether you’re building a blog, e-commerce platform, or any other type of application, understanding and leveraging one-to-many relationships can greatly enhance the efficiency and organization of your code. Laravel’s Eloquent ORM truly shines in its ability to simplify complex database interactions, making it a preferred choice for developers building modern web applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e341ee13969" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>