проблема со вставкой в ​​laravel с модулем аутентификации - PullRequest
1 голос
/ 05 августа 2020

Я новичок ie в Laravel, только начинаю возиться с модулем auth, я сгенерировал материал basi c и добавил некоторые поля в миграцию, но после внесения изменений в представление модель и контроллер регистрации регистрация не работает, я пробовал использовать var_dump, но он ничего не показывает (или, по крайней мере, я точно не знаю, куда его поместить)

Вот мой код:

Пользователь

 <?php

namespace App;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable
{
    use Notifiable;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'surname', 'business_name','user_document','user_document','nit','email','password','business_base_url','location','address','city','currency','phone1','phone2','payment_platform','active_payment','password','status','active',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];

    public function Store_details(){
        return $this->hasOne('App\Store_details');
    }
}

RegisterController

    <?php
    
    namespace App\Http\Controllers\Auth;
    
    use App\Http\Controllers\Controller;
    use App\Providers\RouteServiceProvider;
    use App\User;
    use Illuminate\Foundation\Auth\RegistersUsers;
    use Illuminate\Support\Facades\Hash;
    use Illuminate\Support\Facades\Validator;
    
    class RegisterController extends Controller
    {
        /*
        |--------------------------------------------------------------------------
        | Register Controller
        |--------------------------------------------------------------------------
        |
        | This controller handles the registration of new users as well as their
        | validation and creation. By default this controller uses a trait to
        | provide this functionality without requiring any additional code.
        |
        */
    
        use RegistersUsers;
    
        /**
         * Where to redirect users after registration.
         *
         * @var string
         */
        protected $redirectTo = RouteServiceProvider::HOME;
    
        /**
         * Create a new controller instance.
         *
         * @return void
         */
        public function __construct()
        {
            $this->middleware('guest');
        }
    
        /**
         * Get a validator for an incoming registration request.
         *
         * @param  array  $data
         * @return \Illuminate\Contracts\Validation\Validator
         */
        protected function validator(array $data){
    
            return Validator::make($data, [
                'name' => ['required', 'string', 'max:255'],
                'surname' => ['required', 'string', 'max:255'],
                'business_name' => ['required', 'string', 'max:255', 'unique:users'],
                'user_document' => ['required', 'string', 'max:255', 'unique:users'],
                'nit' => ['required', 'string', 'max:255', 'unique:users'],
                'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
                'password' => ['required', 'string', 'min:8', 'max:12','confirmed'],
                'business_base_url' => ['required', 'string', 'min:5','max:12','unique:users'],
                'location' => ['required', 'string', 'min:8', 'max:12','confirmed'],
                'address' => ['required', 'string', 'min:10','max:20', 'confirmed'],
                'city' => ['required', 'string', 'min:4', 'max:20','confirmed'],
                'currency' => ['required', 'string', 'min:2', 'max:3','confirmed'],
                'phone1' => ['required', 'string', 'min:5','max:10','confirmed'],
                'phone2' => ['required', 'string', 'min:5','max:10', 'confirmed'],
                'payment_platform' => ['required', 'string', 'min:5','max:10', 'confirmed'],
                'active_payment' => ['required', 'string', 'min:1','max:1', 'confirmed'],
                'status' => ['required', 'string', 'min:1','max:1', 'confirmed'],
                'active' => ['required', 'string', 'min:1','max:1', 'confirmed'],
            ]);
        }
    
        
    
        /**
         * Create a new user instance after a valid registration.
         *
         * @param  array  $data
         * @return \App\User
         */
        protected function create(array $data){
    
            return User::create([
                'name' => $data['name'],
                'surname' => $data['surname'],
                'user_document' => $data['user_document'],
                'business_name' => $data['business_name'],
                'business_base_url' => $data['business_base_url'],
                'nit' => $data['nit'],
                'location' => $data['location'],
                'address' => $data['address'],
                'email' => $data['email'],
                'city' => $data['city'],
                'currency' => $data['currency'],
                'phone1' => $data['phone1'],
                'phone2' => $data['phone2'],
                'payment_platform' => $data['payment_platform'],
                'active_payment' => $data['active_payment'],
                'status' => $data['status'],
                'active' => $data['active'],
                'password' => Hash::make($data['password']),
            ]);
        }
    }

register.blade. php

@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">{{ __('Registro') }}</div>

                <div class="card-body">
                    <form method="POST" action="{{ route('register') }}">
                        @csrf

                        <div class="form-group row">
                            <label for="name" class="col-md-4 col-form-label text-md-right">{{ __('Nombre') }}</label>

                            <div class="col-md-6">
                                <input id="name" type="text" class="form-control @error('name') is-invalid @enderror" name="name" value="{{ old('name') }}" required autocomplete="name" autofocus>

                                @error('name')
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                        </div>

                        <div class="form-group row">
                            <label for="surname" class="col-md-4 col-form-label text-md-right">{{ __('Apellido') }}</label>

                            <div class="col-md-6">
                                <input id="surname" type="text" class="form-control @error('surname') is-invalid @enderror" name="surname" value="{{ old('surname') }}" required autocomplete="surname" autofocus>

                                @error('surname')
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                        </div>

                        <div class="form-group row">
                            <label for="user_document" class="col-md-4 col-form-label text-md-right">{{ __('Documento') }}</label>

                            <div class="col-md-6">
                                <input id="user_document" type="text" class="form-control @error('user_document') is-invalid @enderror" name="user_document" value="{{ old('user_document') }}" required autocomplete="user_document" autofocus>

                                @error('user_document')
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                        </div>

                        <div class="form-group row">
                            <label for="nit" class="col-md-4 col-form-label text-md-right">{{ __('Nombre del negocio') }}</label>

                            <div class="col-md-6">
                                <input id="business_name" type="text" class="form-control @error('business_name') is-invalid @enderror" name="business_name" value="{{ old('business_name') }}" required autocomplete="business_name" autofocus>

                                @error('user_document')
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                        </div>

                        <div class="form-group row">
                            <label for="business_base_url" class="col-md-4 col-form-label text-md-right">{{ __('Url del negocio') }}</label>

                            <div class="col-md-6">
                                <input id="business_base_url" type="text" class="form-control @error('business_base_url') is-invalid @enderror" name="business_base_url" value="{{ old('business_base_url') }}" required autocomplete="business_name" autofocus>

                                @error('user_document')
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                        </div>

                        <div class="form-group row">
                            <label for="nit" class="col-md-4 col-form-label text-md-right">{{ __('Nit') }}</label>

                            <div class="col-md-6">
                                <input id="nit" type="text" class="form-control @error('nit') is-invalid @enderror" name="nit" value="{{ old('nit') }}" required autocomplete="nit" autofocus>

                                @error('user_document')
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                        </div>

                        <div class="form-group row">
                            <label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail') }}</label>

                            <div class="col-md-6">
                                <input id="email" type="email" class="form-control @error('email') is-invalid @enderror" name="email" value="{{ old('email') }}" required autocomplete="email">

                                @error('email')
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                        </div>

                        <div class="form-group row">
                            <label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Contraseña') }}</label>

                            <div class="col-md-6">
                                <input id="password" type="password" class="form-control @error('password') is-invalid @enderror" name="password" required autocomplete="new-password">

                                @error('password')
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                @enderror
                            </div>
                        </div>

                        <div class="form-group row">
                            <label for="password-confirm" class="col-md-4 col-form-label text-md-right">{{ __('Confirmar contraseña') }}</label>

                            <div class="col-md-6">
                                <input id="password-confirm" type="password" class="form-control" name="password_confirmation" required autocomplete="new-password">
                            </div>
                        </div>

                        <div class="form-group row mb-0">
                            <div class="col-md-6 offset-md-4">
                                <button type="submit" class="btn btn-primary">
                                    {{ __('Registro') }}
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

Я попытался выполнить поиск в папке журналов, но не нашел ничего подходящего.

Когда я отправляю форму, она не отображает никаких ошибок, просто ничего не делает после отправить.

Я буду очень признателен, если кто-нибудь объяснит мне, как отладить это ...

Заранее спасибо!

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