laravel validation present code example

Example 1: laravel exists validation

'state_id' => 'exists:states,id'

Example 2: laravel validation show

<!-- /resources/views/post/create.blade.php -->

<h1>Create Post</h1>

@if ($errors->any())
    <div class="alert alert-danger">
        <ul>
            @foreach ($errors->all() as $error)
                <li>{{ $error }}</li>
            @endforeach
        </ul>
    </div>
@endif

<!-- Create Post Form -->

Example 3: laravel form validation

php artisan make:controller ValidationController --plain

Example 4: laravel validation

Validator::extend('foo', 'FooValidator@validate');

Tags:

Sql Example