Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      June 3, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      June 3, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      June 3, 2025

      How To Prevent WordPress SQL Injection Attacks

      June 3, 2025

      SteelSeries reveals new Arctis Nova 3 Wireless headset series for Xbox, PlayStation, Nintendo Switch, and PC

      June 3, 2025

      The Witcher 4 looks absolutely amazing in UE5 technical presentation at State of Unreal 2025

      June 3, 2025

      Razer’s having another go at making it so you never have to charge your wireless gaming mouse, and this time it might have nailed it

      June 3, 2025

      Alienware’s rumored laptop could be the first to feature NVIDIA’s revolutionary Arm-based APU

      June 3, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      easy-live2d – About Make your Live2D as easy to control as a pixi sprite! Live2D Web SDK based on Pixi.js.

      June 3, 2025
      Recent

      easy-live2d – About Make your Live2D as easy to control as a pixi sprite! Live2D Web SDK based on Pixi.js.

      June 3, 2025

      From Kitchen To Conversion

      June 3, 2025

      Perficient Included in Forrester’s AI Technical Services Landscape, Q2 2025

      June 3, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      SteelSeries reveals new Arctis Nova 3 Wireless headset series for Xbox, PlayStation, Nintendo Switch, and PC

      June 3, 2025
      Recent

      SteelSeries reveals new Arctis Nova 3 Wireless headset series for Xbox, PlayStation, Nintendo Switch, and PC

      June 3, 2025

      The Witcher 4 looks absolutely amazing in UE5 technical presentation at State of Unreal 2025

      June 3, 2025

      Razer’s having another go at making it so you never have to charge your wireless gaming mouse, and this time it might have nailed it

      June 3, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»How to delete the data from Database using Laravel 11

    How to delete the data from Database using Laravel 11

    February 12, 2025

    In this tutorial, we will learn How to delete the data from the database using Laravel 11. To delete data in Laravel 11, follow these steps:

    Files created for this tutorial

    fetch.blade.php (resources/views/fetch.blade.php)

    deleteController.php (app/Http/Controllers/deleteController.php)

    web.php (routes/web.php)

    The User Data looks like before the delete.

    Laravel-Data-delete

    Step 1:  Create the Fetch View

    Already created in the previous tutorial

    @if(session('success'))
                <div class="alert alert-success">{{ session('success') }}</div>
            @endif
    
            @if(session('error'))
            <div class="alert alert-danger">{{ session('error') }}</div>
            @endif
                <table class="table table-striped table-hover table-bordered">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>First Name</th>
                            <th>Last Name</th>
                            <th>Email id</th>
                            <th>Mobile No</th>
                            <th>Address</th>
                            <th>City</th>
                            <th>State</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach ($data as $id => $user )
                        <tr>
                            <td>1</td>
                            <td>{{ $user->firstName }}</td>
                            <td>{{ $user->lastName }}</td>
                            <td>{{ $user->emailId }}</td>
                            <td>{{ $user->mobileNumber }}</td>
                            <td>{{ $user->address }}</td>
                            <td>{{ $user->city }}</td>
                            <td>{{ $user->state }}</td>
                            <td>    <a class="btn btn-primary btn-sm" href="{{ route('update', $user->id) }}">Edit</a></td>
                        </tr>
                        @endforeach
                          
                    </tbody>
                </table>

    Step 2: Create a controller for data deleting.

    php artisan make:controller deleteController

    Add logic to delete data in the controller (app/Http/Controllers/deleteController.php)

    <?php
    namespace AppHttpControllers;
    use IlluminateSupportFacadesDB;
    use IlluminateHttpRequest;
    
    class deleteController extends Controller
    {
        public function deleteUser(string $id){
            $user=DB::table('tblusers')
            ->where('id', $id)
            ->delete();
            if($user){
                return redirect()->route('fetch')->with('success', 'Data deleted.');
            } else{
                return redirect()->route('fetch')->with('Something went wrong . Please Try again.');
            }
        }
    }

    How to run the Script

    1. Download the project zip file

    2. Extract the file and copy insert-app  folder

    3. Paste inside root directory (for xampp xampp/htdocs, for wamp wamp/www, for lamp var/www/Html)

    4.Open PHPMyAdmin (http://localhost/phpmyadmin)

    5. Create a database with the name  userdb

    6. Import userdb.sql file(given inside the zip package in SQL file folder)

    7. Run these command

    PS C :> cd xampp/htdocs/insert-app

    PS C:xampphtdocsinsert-app> php artisan serve

    8. After that open the browser and run the script

    http://127.0.0.1:8000/fetch

    Download Full source code(Delete Data Using Laravel11)
    Size: 27.5 MB
    Version: V 1.0
    Download Now!

    The post How to delete the data from Database using Laravel 11 appeared first on PHPGurukul.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleNew Windows 11 reference hints Start Menu Recommendations might be optional
    Next Article How to Start a Fiction Blog and Rank in 28 Days on Google: The Ultimate SEO Guide

    Related Posts

    Security

    Alert: Malicious RubyGems Impersonate Fastlane Plugins, Steal CI/CD Data

    June 3, 2025
    Security

    Critical CVSS 9.6: IBM QRadar & Cloud Pak Security Flaws Exposed

    June 3, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    Netflix introduces a new ‘dialogue only’ subtitles option (crowd cheers)

    News & Updates

    M-Trends 2025: Data, Insights, and Recommendations From the Frontlines

    Security

    This $45 foldable keyboard is a game-changer for working professionals on the move

    Development

    ChatGPT’s New Search Feature

    Development

    Highlights

    CVE-2025-4251 – PCMan FTP Server Remote Buffer Overflow

    May 4, 2025

    CVE ID : CVE-2025-4251

    Published : May 4, 2025, 10:15 p.m. | 1 hour, 17 minutes ago

    Description : A vulnerability was found in PCMan FTP Server 2.0.7 and classified as critical. This issue affects some unknown processing of the component RMDIR Command Handler. The manipulation leads to buffer overflow. The attack may be initiated remotely. The exploit has been disclosed to the public and may be used.

    Severity: 7.3 | HIGH

    Visit the link for more details, such as CVSS details, affected products, timeline, and more…

    5 Ways to Improve Caregiver Experiences for Better Outcomes

    November 19, 2024

    when – extremely simple personal calendar program

    July 3, 2024

    Meet Amazon Nova Act: An AI Agent that can Automate Web Tasks

    April 2, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.