D
D
Dmitry2019-06-26 16:18:58
Laravel
Dmitry, 2019-06-26 16:18:58

Why is there a missing class error in Laravel?

Hello. Installed

laravel-jsvalidation

I did everything as here then
again
composer dump-autoload

connected in view as in the example,
that is, like this:
<!-- Laravel Javascript Validation -->
<script type="text/javascript" src="{{ asset('vendor/jsvalidation/js/jsvalidation.js')}}"></script>
{!! JsValidator::formRequest('App\Http\Requests\MyFormRequest') !!}

resources/views/layouts/admin.blade.php

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Админ панель</title>
    <link rel="canonical" href="https://getbootstrap.com/docs/4.0/examples/dashboard/">

    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" href="{{ URL::to('css/bootstrap-min.css') }}">

    <!-- Alertyfy CSS -->
    <link rel="stylesheet" href="{{ URL::to('plugins/alertyfy/themes/alertify.core.css') }}">
    <link rel="stylesheet" href="{{ URL::to('plugins/alertyfy/themes/alertify.default.css') }}">
    <link rel="stylesheet" href="{{ URL::to('plugins/alertyfy/themes/alertify.bootstrap.css') }}">

    <!-- Custom styles for this template -->
    <link href="/css/dashboard.css" rel="stylesheet">
</head>

<body>
<nav class="navbar navbar-toggleable-md navbar-inverse fixed-top bg-inverse">
    <button class="navbar-toggler navbar-toggler-right hidden-lg-up" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>
    <a class="navbar-brand" href="/admin">Панель управления</a>

    <div class="collapse navbar-collapse" id="navbarsExampleDefault">
        <ul class="navbar-nav mr-auto">
            <li class="nav-item active">
                <a class="nav-link" href="/admin">Главная <span class="sr-only">(current)</span></a>
            </li>
        </ul>
    </div>
</nav>

<div class="container-fluid">
    <div class="row">
        <nav class="col-sm-3 col-md-2 hidden-xs-down bg-faded sidebar">
            <ul class="nav nav-pills flex-column">
                <li class="nav-item">
                    <a class="nav-link {{ active(['admin.products', 'admin.products.*', 'not:admin.products.categories', 'not:admin.products.categories.*']) }}" href="{!! route('admin.products') !!}">Товары</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link {{ active(['admin.products.categories', 'admin.products.categories.*']) }}" href="{!! route('admin.products.categories') !!}">Категории товаров <span class="sr-only">(current)</span></a>
                </li>
            </ul>
        </nav>

        @yield('content')
    </div>
</div>

<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="{{ URL::to('js/custom-js/jquery-3.2.1.js') }}"></script>
<script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="{{ URL::to('plugins/alertyfy/lib/alertify.js') }}"></script>

<script src="{{ URL::to('plugins/tinymce/tinymce.min.js') }}"></script>
<script src="{{ URL::to('js/custom-js/tiny-mce-init-admin.js') }}"></script>

{{--<script src="{{ URL::to('plugins/jquery-validation/jquery.validate.min.js') }}"></script>
<script src="{{ URL::to('js/custom-js/init-admin.js') }}"></script>--}}

<!-- Laravel Javascript Validation -->
<script type="text/javascript" src="{{ url('vendor/jsvalidation/js/jsvalidation.js')}}"></script>
{!! JsValidator::formRequest('App/Http/Requests/ProductsRequest') !!}

@yield('js')

@include('inc.messages')
</body>
</html>

app/Http/Requests/ProductsRequest.php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class ProductsRequest extends FormRequest
{
    public function rules()
    {
        return [
            'title' => 'required|string|min:4|max:25',
            'slug' => array(
                'required',
                'string',
                'min:4',
                'max:25',
                'regex:/^[a-z0-9а-яё-]+$/u',
                Rule::unique('products')->ignore($this->id),
            ),
            'excerpt' => 'required|string|min:4|max:100',
            'content' => 'required|string|min:4|max:300',
            'descrtitle' => 'required|string|min:4|max:100',
            'descrtext' => 'required|string|min:4|max:300',
            'descr' => 'required|string|min:4|max:300',
            'regular_price' => [
                'required',
                'regex:/\d+/',
            ],
            'sale_price' => '',
            'discount' => [
                'required',
                'min:0',
                'max:100',
                'regex:/^\d+(\.\d{1,2})?$/',
            ],
            'currency' => 'string',
            'image' => 'mimes:jpeg,jpg,png,gif|max:10000',
            'tab_bg' => 'mimes:jpeg,jpg,png,gif|max:10000',
            'product_description_tab_content' => 'max:10000',
            'product_ingredients_tab_content' => 'max:10000',
            'product_usage_tab_content' => 'max:10000',
            'is_reccomended' => '',
        ];
    }
}

It gives an error
ErrorException (E_ERROR)
Class App/Http/Requests/ProductsRequest does not exist (View: D:\react\laravel-react\resources\views\layouts\admin.blade.php) (View: D:\react\laravel-react \resources\views\layouts\admin.blade.php)

Am I forgetting something? Where did I go wrong?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2019-06-26
@ddimonn8080

{!! JsValidator::formRequest(' App/Http/Requests/ProductsRequest ') !!}

Namespaces are written with a backslash:
App\Http\Requests\ProductsRequest

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question