Laravel Redirect To Another URL / Web Page - HTTP Laravel Redirects

Laravel 5.7 CRUD Tutorial With Example from scratch

Today, We want to share with you Laravel 5.7 CRUD Tutorial With Example.In this post we will show you Laravel 5.7 CRUD (Create Read Update Delete) Example from scratch, hear for Laravel 5.7 CRUD Application for Starter we will give you demo and example for implement.In this post, we will learn about Laravel 5.7 – simple crud operation with example with an example.

Laravel 5.7 CRUD Tutorial With Example

There are the Following The simple About Laravel 5.7 CRUD Tutorial With Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop Laravel 5.7 Crud Example Tutorial, so the some major files and Directory structures for this example is following below.

Latest Laravel 5.7 Features & New Updates

  • Console Testing
  • Email Verification
  • Filesystem
  • Guest User Gates / Policies
  • Laravel Nova
  • Notification Localization
  • Paginator Links
  • Read / Write Streams
  • Symfony Dump Server
  • URL Callable Syntax
  • URL Generator

Laravel 5.7 Crud Example Tutorial Step By Step

Step 1: Install Laravel 5.7 Project

simple run this commands in terminal.

composer create-project --prefer-dist laravel/laravel atmiyamembers

Step #2: Settings SQL Database

Laravel Project.env files

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=atmiyamembers
DB_USERNAME=root
DB_PASSWORD=

Step #3: Make Laravel 5.7 Model and Database Migration File

Laravel 5.7 Model and Database Migration

php artisan make:model member -m

Make >> member.php file as well as Make a create_members_table.php migration

public function up()
    {
        Schema::create('members', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('membertype');
            $table->string('department');
            $table->text('groupname');
            $table->timestamps();
        });
    }

php artisan migrate

Step #4: Create a View File

resources/views/member.blade.php


  
    
    <title>Laravel 5.7 CRUD Tutorial With Example </title>
    
    
    
    
  
  
    <div class="pakainfo container">
      <h2>Laravel 5.7 CRUD Tutorial With Example</h2><br />
      <form method="post" action="{{url('create')}}">
        @csrf
        <div class="pakainfo row">
          <div class="col-md-4"></div>
          <div class="form-group col-md-4">
            <label for="membertype">MemberType:</label>
            
          </div>
        </div>
        <div class="row">
          <div class="col-md-4"></div>
            <div class="form-group col-md-4">
              <label for="department">Department:</label>
              
            </div>
          </div>
          <div class="pakainfo row">
          <div class="col-md-4"></div>
            <div class="form-group col-md-4">
            <label for="groupname">Group Name:</label>
            
            </div>
          </div>
        <div class="row">
          <div class="col-md-4"></div>
          <div class="form-group col-md-4">
            <button type="submit" class="btn btn-success">Submit</button>
          </div>
        </div>
      </form>
    </div>
  

Step #5: Make Laravel 5.7 controller

php artisan make:controller MemberController

MemberController.php
//MemberController.php

public function create()
    {
        return view('membercreate');
    }

Step #6: Laravel 5.7 Route

web.php

//web.php

Route::get('create','[email protected]');
Route::post('create','[email protected]');
Route::get('member','[email protected]');
Route::get('/edit/member/{id}','[email protected]');
Route::post('/edit/member/{id}','[email protected]');
Route::delete('/delete/member/{id}','[email protected]');

Step #7: Save data to Laravel into the database

MemberController.php

public function store(Request $request)
    {
        $member= new \App\member;
        $member->membertype=$request->get('membertype');
        $member->department=$request->get('department');
        $member->groupname=$request->get('groupname');
        $member->save();
        return redirect('member')->with('success', 'Data has been added');
    }

Step #8: MAke an index page(root) to Listing All the data

//MemberController.php

//MemberController.php

public function index()
    {
        $members=\App\member::all();
        return view('memberindex',compact('members'));
    }

memberindex.blade.php

<!-- memberindex.blade.php -->



  
    
    <title>Index Page - Laravel 5.7 CRUD Tutorial With Example</title>
    
  
  
    <div class="container">
    <br />
    @if (\Session::has('success'))
      <div class="alert alert-success">
        <p>{{ \Session::get('success') }}</p>
      </div><br />
     @endif
     <h2>Formula1 Race</h2>
    <table class="table table-striped">
    <thead>
      <tr>
        <th>ID</th>
        <th>MemberType</th>
        <th>Department</th>
        <th>Group Name</th>
        <th colspan="2">Action</th>
      </tr>
    </thead>
    <tbody>

      @foreach($members as $member)
      <tr>
        <td>{{$member['id']}}</td>
        <td>{{$member['membertype']}}</td>
        <td>{{$member['department']}}</td>
        <td>{{$member['groupname']}}</td>

        <td><a href="{{action('[email protected]', $member['id'])}}" class="btn btn-warning">Edit</a></td>
        <td>
          <form action="{{action('[email protected]', $member['id'])}}" method="post">
            @csrf
            
            <button class="pakainfo btn btn-danger" type="submit">Delete</button>
          </form>
        </td>
      </tr>
      @endforeach
    </tbody>
  </table>
  </div>
  

Step #9: Laravel 507 edit view for updating

MemberController.php

//MemberController.php

 public function edit($id)
    {
        $member = \App\member::find($id);
        return view('memberedit',compact('member','id'));
    }

resources/views/memberedit.blade.php
<!-- memberedit.blade.php -->



  
    
    <title>Laravel 5.7 CRUD Tutorial With Example</title>
    
  
  
    <div class="container">
      <h2>Member - Edit Data</h2><br />
        <form method="post" action="{{action('[email protected]', $id)}}">
        @csrf
        <div class="row">
          <div class="col-md-4"></div>
          <div class="form-group col-md-4">
            <label for="membertype">MemberType:</label>
            membertype}}">
          </div>
        </div>
        <div class="pakainfo row">
          <div class="col-md-4"></div>
            <div class="form-group col-md-4">
              <label for="department">Department:</label>
              department}}">
            </div>
          </div>
        <div class="pakainfo row">
          <div class="col-md-4"></div>
            <div class="form-group col-md-4">
              <label for="groupname">Group Name:</label>
              groupname}}">
            </div>
          </div>
        <div class="row">
          <div class="col-md-4"></div>
          <div class="form-group col-md-4">
            <button type="submit" class="pakainfo btn btn-success" style="margin-left:38px">Update</button>
          </div>
        </div>
      </form>
    </div>
  

MemberController.php

//MemberController.php

public function update(Request $request, $id)
    {
        $member= \App\member::find($id);
        $member->membertype=$request->get('membertype');
        $member->department=$request->get('department');
        $member->groupname=$request->get('groupname');
        $member->save();
        return redirect('member')->with('success', 'Member has been updated');
    }

Step #10: Delete the Member

MemberController.php

//MemberController.php

public function destroy($id)
    {
        $member = \App\member::find($id);
        $member->delete();
        return redirect('member')->with('success','Member has been deleted');
    }

Angular 6 CRUD Operations Application Tutorials

Read :

  Laravel 5.7 JQuery Form Validation Example Tutorial

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Laravel 5.7 CRUD Tutorial With Example.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.