Laravel 6 Required With All Validation Example

Today, We want to share with you Laravel 6 Required With All Form Validation.In this post we will show you Form Validation Example In Laravel 6, hear for Laravel 6 validation with error message we will give you demo and example for implement.In this post, we will learn about Laravel 6 Form Validation Tutorial Example From Scratch with an example.

Laravel 6 Required With All Form Validation

There are the Following The simple About Laravel 6 Form Validation with Error Messages Full Information With Example and source code.

As I will cover this Post with live Working example to develop laravel form validation before submit, so the laravel validation unique except is used for this example is following below.

List of Laravel validation rules

  • Accepted
  • Active URL
  • After (Date)
  • After Or Equal (Date)
  • Alpha
  • Alpha Dash
  • Alpha Numeric
  • Array
  • Bail
  • Before (Date)
  • Before Or Equal (Date)
  • Between
  • Boolean
  • Confirmed
  • Date
  • Date Equals
  • Date Format
  • Different
  • Digits
  • Digits Between
  • Dimensions (Image Files)
  • Distinct
  • E-Mail
  • Ends With
  • Exists (Database)
  • File
  • Filled
  • Greater Than
  • Greater Than Or Equal
  • Image (File)
  • In
  • In Array
  • Integer
  • IP Address
  • JSON
  • Less Than
  • Less Than Or Equal
  • Max
  • MIME Types
  • MIME Type By File Extension
  • Min
  • Not In
  • Not Regex
  • Nullable
  • Numeric
  • Password
  • Present
  • Regular Expression
  • Required
  • Required If
  • Required Unless
  • Required With
  • Required With All
  • Required Without
  • Required Without All
  • Same
  • Size
  • Sometimes
  • Starts With
  • String
  • Timezone
  • Unique (Database)
  • URL
  • UUID
Read Also:  Vue.js Get first and last value of list-item (li)

Create Controller Souurce Code

ShopController.php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class ShopController extends Controller
{
    public function create()
    {
    	return view('member-create');
    }

    public function save_data(Request $request)
    {
    	$input = $request->all();

    	$request->validate([
    		'phone' => 'required_with_all:member_first_name,member_last_name',
    		'email' => 'required',
    	]);

    	return redirect()->back();
    }
}

Create Laravel 6 Blade File

resources\views\member-create.blade.php

<!DOCTYPE html>
<html>
<head>
    <title>Laravel 6 - Required With All Validation</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css"/>	
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
    <div class="container">
        <div class="row">
            <div class="col-md-6 offset-3">
                <div class="card mt-5">
                    <div class="card-header text-center bg-primary">
                        <h2 class="text-white"> <strong>Laravel 6 Required With All Validation</strong></h2>
                        <p>PHP Laravel 6 - Required With All Validation Example</p>
                    </div>
                    <div class="card-body">
                        @if(count($errors) > 0)
                            <ul class="alert alert-danger">
                            @foreach($errors->all() as $error)
                                <li>{{ $error }}</li>
                            @endforeach
                            </ul>
                        @endif
                        <form action="{{ route('member.save_data') }}" method="post">
                            @csrf
                            <div class="form-group dsp">
                                <label>Member Name :- </label>
                                <input type="text" name="member_first_name" class="form-control tamilrok" value="{{ old('member_first_name') }}">
                            </div>
                            <div class="form-group dsp">
                                <label>Last Name :- </label>
                                <input type="text" name="member_last_name" class="form-control tamilrok" value="{{ old('member_last_name') }}">
                            </div>
                            <div class="form-group dsp">
                                <label>Phone No. :- </label>
                                <input type="text" name="phone" class="form-control tamilrok" value="{{ old('phone') }}">
                            </div>
                            <div class="form-group dsp">
                                <label>Email :- </label>
                                <input type="email" name="email" class="form-control tamilrok" value="{{ old('email') }}">
                            </div>
                            <div class="text-center tamilrok">
                                <button class="btn btn-success"><i class="fa fa-floppy-o" aria-hidden="true"></i> Save </button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>

Web Programming Tutorials Example with Demo

Read :

Read Also:  Simple Crud operations in php using mysql Example

Summary

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

I hope you get an idea about Laravel 6 Validating many input fields on a form before SUBMIT.
I would like to have feedback on my infinityknow.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.