Недопустимый тип смещения в isset или пуст (Laravel 7) - PullRequest
0 голосов
/ 30 марта 2020

У меня есть некоторые проблемы в моем laravel проекте. Когда я запускаю свое приложение и обновляю sh приложение в браузере, оно показывает мне это сообщение об ошибке:

Недопустимый тип смещения в isset или пуст (View: / Users / inf / open-source / application / resources / views / auth / register.blade. php)

Промежуточное программное обеспечение: локализация. php

<?php

namespace App\Http\Middleware;

use App;
use Closure;

class Localization
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if (session()->has('locale')) {
            App::setLocale(session()->get('locale'));
        }

        return $next($request);
    }
}

Контроллеры: LocalizationController

<?php

namespace App\Http\Controllers\Web;

use App;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request; 
use RealRashid\SweetAlert\Facades\Alert;

class LocalizationController extends Controller
{
    public function SiteLocalization($locale)
    {
        App::setLocale($locale);
        // store the locale in session so that the middleware can register it
        session()->put('locale', $locale);

        toast('The language has been changed successfully.','success');

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

Ресурсы / auth / register.blade. php

<form id="registerForm" method="POST" action="{{ route('register') }}">
    @csrf
    <fieldset>
        <div class="form-row">
                <div class="form-group form-group-auth col-md-6 @error('firstname') is-invalid @enderror">
                    <label for="firstname">{{ __('First Name') }} <span class="text-danger">*</span></label>
                    <div class="input-group">
                        <div class="input-group-prepend">
                            <span class="input-group-text"><ion-icon name="people-outline"></ion-icon></span>
                        </div><!-- End input-group-prepend -->
                        <input type="text" id="firstname" class="form-control form-control-auth" name="firstname" value="{{ old('firstname') }}" placeholder="First Name *" autofocus />
                    </div><!-- End input-group -->
                    @error('firstname')
                    <div class="invalid-feedback invalid-feedback-msg d-block">
                        <p class="mb-0"><span class="mr-1"><i class="fas fa-exclamation-triangle"></i></span> {{ $message }}</p>
                    </div>
                    @enderror
                </div><!-- End form-group -->
                <div class="form-group form-group-auth col-md-6 @error('lastname') is-invalid @enderror">
                    <label for="lastname">{{ __('Last Name') }} <span class="text-danger">*</span></label>
                    <div class="input-group">
                        <div class="input-group-prepend">
                            <span class="input-group-text"><ion-icon name="people-outline"></ion-icon></span>
                        </div><!-- End input-group-prepend -->
                        <input type="text" id="lastname" class="form-control form-control-auth" name="lastname" value="{{ old('lastname') }}" placeholder="Last Name *" />
                   </div><!-- End input-group -->
                   @error('lastname')
                   <div class="invalid-feedback invalid-feedback-msg d-block">
                       <p class="mb-0"><span class="mr-1"><i class="fas fa-exclamation-triangle"></i></span> {{ $message }}</p>
                   </div>
                   @enderror
                </div><!-- End form-group -->
        </div><!-- End form-row -->
        <div class="form-group form-group-auth @error('name') is-invalid @enderror">
            <label for="name">{{ __('Username') }} <span class="text-danger">*</span></label>
            <div class="input-group">
                <div class="input-group-prepend">
                    <span class="input-group-text"><ion-icon name="person-outline"></ion-icon></span>
                </div><!-- End input-group-prepend -->
                <input type="text" id="name" class="form-control form-control-auth" name="name" value="{{ old('name') }}" placeholder="Username *" />
            </div><!-- End input-group -->
            @error('name')
                <div class="invalid-feedback invalid-feedback-msg d-block">
                    <p class="mb-0"><span class="mr-1"><i class="fas fa-exclamation-triangle"></i></span> {{ $message }}</p>
                </div>
            @enderror
        </div><!-- End form-group -->
        <div class="form-group form-group-auth @error('email') is-invalid @enderror">
            <label for="email">{{ __('E-mail Address') }} <span class="text-danger">*</span></label>
            <div class="input-group">
                <div class="input-group-prepend">
                    <span class="input-group-text"><ion-icon name="mail-outline"></ion-icon></span>
                </div><!-- End input-group-prepend -->
                    <input type="email" id="email" class="form-control form-control-auth" name="email" value="{{ old('email') }}" placeholder="E-mail Address *" />
                </div><!-- End input-group -->
                @error('email')
                <div class="invalid-feedback invalid-feedback-msg d-block">
                    <p class="mb-0"><span class="mr-1"><i class="fas fa-exclamation-triangle"></i></span> {{ $message }}</p>
                </div>
                @enderror
        </div><!-- End form-group -->
        <div class="form-row">
            <div class="form-group form-group-auth col-md-6 @error('password') is-invalid @enderror">
                <label for="password">{{ __('Password') }} <span class="text-danger">*</span></label>
                <div class="input-group">
                    <div class="input-group-prepend">
                        <span class="input-group-text">
                            <i class="ion" v-bind:class="[passwordIcon]" v-on:click="hidePassword = !hidePassword"></i>
                        </span>
                    </div><!-- End input-group-prepend -->
                    <input :type="passwordType"
                    v-model="registration.password" 
                    id="password" 
                    class="form-control form-control-auth" 
                    name="password" 
                    placeholder="Password *" 
                    data-container="body" 
                    data-toggle="popover" 
                    data-trigger="hover" 
                    data-placement="top" 
                    data-content="Make sure it's at least 10 characters including a one lowercase letter, one uppercase letter, one digit, and special character." />
                </div><!-- End input-group -->
                @error('password')
                <div class="invalid-feedback invalid-feedback-msg d-block">
                    <p class="mb-0"><span class="mr-1"><i class="fas fa-exclamation-triangle"></i></span> {{ $message }}</p>
                </div>
                @enderror
            </div><!-- End form-group -->
            <div class="form-group form-group-auth col-md-6 @error('password_confirmation') is-invalid @enderror">
                <label for="password-confirm">{{ __('Confirm Password') }} <span class="text-danger">*</span></label>
                <div class="input-group">
                    <div class="input-group-prepend">
                        <span class="input-group-text">
                            <i class="ion" v-bind:class="[RepeatpasswordIcon]" v-on:click="hideRepeatPassword = !hideRepeatPassword"></i>
                        </span>
                    </div><!-- End input-group-prepend -->
                    <input :type="RepeatpasswordType"
                    v-model="registration.password_confirmation"
                    id="password-confirm" 
                    class="form-control form-control-auth" 
                    name="password_confirmation" 
                    placeholder="Confirm Password *" />
                </div><!-- End input-group -->
                @error('password_confirmation')
                <div class="invalid-feedback invalid-feedback-msg d-block">
                    <p class="mb-0"><span class="mr-1"><i class="fas fa-exclamation-triangle"></i></span> {{ $message }}</p>
                </div>
                @enderror
            </div><!-- End form-group -->
        </div><!-- End form-row -->
    </fieldset>
</form>

1 Ответ

0 голосов
/ 30 марта 2020

отправьте значение сообщения $ на блейд

или

используйте @ перед переменной, например

{{ @$message }}

или

{{ @$message?:"default message" }}
<form id="registerForm" method="POST" action="{{ route('register') }}">
                @csrf
                <fieldset>
                    <div class="form-row">
                            <div class="form-group form-group-auth col-md-6 @error('firstname') is-invalid @enderror">
                                <label for="firstname">{{ __('First Name') }} <span class="text-danger">*</span></label>
                                <div class="input-group">
                                    <div class="input-group-prepend">
                                        <span class="input-group-text"><ion-icon name="people-outline"></ion-icon></span>
                                    </div><!-- End input-group-prepend -->
                                    <input type="text" id="firstname" class="form-control form-control-auth" name="firstname" value="{{ old('firstname') }}" placeholder="First Name *" autofocus />
                                </div><!-- End input-group -->
                                @error('firstname')
                                <div class="invalid-feedback invalid-feedback-msg d-block">
                                    <p class="mb-0"><span class="mr-1"><i class="fas fa-exclamation-triangle"></i></span> {{ @$message }}</p>
                                </div>
                                @enderror
                            </div><!-- End form-group -->
                            <div class="form-group form-group-auth col-md-6 @error('lastname') is-invalid @enderror">
                                <label for="lastname">{{ __('Last Name') }} <span class="text-danger">*</span></label>
                                <div class="input-group">
                                    <div class="input-group-prepend">
                                        <span class="input-group-text"><ion-icon name="people-outline"></ion-icon></span>
                                    </div><!-- End input-group-prepend -->
                                    <input type="text" id="lastname" class="form-control form-control-auth" name="lastname" value="{{ old('lastname') }}" placeholder="Last Name *" />
                               </div><!-- End input-group -->
                               @error('lastname')
                               <div class="invalid-feedback invalid-feedback-msg d-block">
                                   <p class="mb-0"><span class="mr-1"><i class="fas fa-exclamation-triangle"></i></span> {{ @$message }}</p>
                               </div>
                               @enderror
                            </div><!-- End form-group -->
                    </div><!-- End form-row -->
                    <div class="form-group form-group-auth @error('name') is-invalid @enderror">
                        <label for="name">{{ __('Username') }} <span class="text-danger">*</span></label>
                        <div class="input-group">
                            <div class="input-group-prepend">
                                <span class="input-group-text"><ion-icon name="person-outline"></ion-icon></span>
                            </div><!-- End input-group-prepend -->
                            <input type="text" id="name" class="form-control form-control-auth" name="name" value="{{ old('name') }}" placeholder="Username *" />
                        </div><!-- End input-group -->
                        @error('name')
                            <div class="invalid-feedback invalid-feedback-msg d-block">
                                <p class="mb-0"><span class="mr-1"><i class="fas fa-exclamation-triangle"></i></span> {{ @$message }}</p>
                            </div>
                        @enderror
                    </div><!-- End form-group -->
                    <div class="form-group form-group-auth @error('email') is-invalid @enderror">
                        <label for="email">{{ __('E-mail Address') }} <span class="text-danger">*</span></label>
                        <div class="input-group">
                            <div class="input-group-prepend">
                                <span class="input-group-text"><ion-icon name="mail-outline"></ion-icon></span>
                            </div><!-- End input-group-prepend -->
                                <input type="email" id="email" class="form-control form-control-auth" name="email" value="{{ old('email') }}" placeholder="E-mail Address *" />
                            </div><!-- End input-group -->
                            @error('email')
                            <div class="invalid-feedback invalid-feedback-msg d-block">
                                <p class="mb-0"><span class="mr-1"><i class="fas fa-exclamation-triangle"></i></span> {{ @$message }}</p>
                            </div>
                            @enderror
                    </div><!-- End form-group -->
                    <div class="form-row">
                        <div class="form-group form-group-auth col-md-6 @error('password') is-invalid @enderror">
                            <label for="password">{{ __('Password') }} <span class="text-danger">*</span></label>
                            <div class="input-group">
                                <div class="input-group-prepend">
                                    <span class="input-group-text">
                                        <i class="ion" v-bind:class="[passwordIcon]" v-on:click="hidePassword = !hidePassword"></i>
                                    </span>
                                </div><!-- End input-group-prepend -->
                                <input :type="passwordType"
                                v-model="registration.password" 
                                id="password" 
                                class="form-control form-control-auth" 
                                name="password" 
                                placeholder="Password *" 
                                data-container="body" 
                                data-toggle="popover" 
                                data-trigger="hover" 
                                data-placement="top" 
                                data-content="Make sure it's at least 10 characters including a one lowercase letter, one uppercase letter, one digit, and special character." />
                            </div><!-- End input-group -->
                            @error('password')
                            <div class="invalid-feedback invalid-feedback-msg d-block">
                                <p class="mb-0"><span class="mr-1"><i class="fas fa-exclamation-triangle"></i></span> {{ @$message }}</p>
                            </div>
                            @enderror
                        </div><!-- End form-group -->
                        <div class="form-group form-group-auth col-md-6 @error('password_confirmation') is-invalid @enderror">
                            <label for="password-confirm">{{ __('Confirm Password') }} <span class="text-danger">*</span></label>
                            <div class="input-group">
                                <div class="input-group-prepend">
                                    <span class="input-group-text">
                                        <i class="ion" v-bind:class="[RepeatpasswordIcon]" v-on:click="hideRepeatPassword = !hideRepeatPassword"></i>
                                    </span>
                                </div><!-- End input-group-prepend -->
                                <input :type="RepeatpasswordType"
                                v-model="registration.password_confirmation"
                                id="password-confirm" 
                                class="form-control form-control-auth" 
                                name="password_confirmation" 
                                placeholder="Confirm Password *" />
                            </div><!-- End input-group -->
                            @error('password_confirmation')
                            <div class="invalid-feedback invalid-feedback-msg d-block">
                                <p class="mb-0"><span class="mr-1"><i class="fas fa-exclamation-triangle"></i></span> {{ @$message }}</p>
                            </div>
                            @enderror
                        </div><!-- End form-group -->
                    </div><!-- End form-row -->
                </fieldset>
            </form>

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...