Я пытаюсь вставить данные в базу данных mysql в laravel, пользователи таблицы по умолчанию, при отправке формы происходит обновление, и данные не вставляются в базу данных, ошибки не отображаются.Я не знаю, где проблема.Мой код указан.
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">{{ __('Register') }}</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">{{ __('Teacher Name') }}</label>
<div class="col-md-6">
<input id="tname" type="text" class="form-control{{ $errors->has('name') ? ' is-invalid' : '' }}" name="tname" value="{{ old('tname') }}" required autofocus>
@if ($errors->has('tname'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('tname') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group row">
<label for="fname" class="col-md-4 col-form-label text-md-right">{{ __('Father Name') }}</label>
<div class="col-md-6">
<input id="name" type="text" class="form-control{{ $errors->has('name') ? ' is-invalid' : '' }}" name="fname" value="{{ old('name') }}" required autofocus>
@if ($errors->has('fname'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('fname') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group row">
<label for="domicile" class="col-md-4 col-form-label text-md-right">{{ __('Domicile') }}</label>
<div class="col-md-6">
<input id="domicile" type="text" class="form-control{{ $errors->has('domicile') ? ' is-invalid' : '' }}" name="domicile" value="{{ old('domicile') }}" required autofocus>
@if ($errors->has('domicile'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('domicile') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group row">
<label for="string" class="col-md-4 col-form-label text-md-right">{{ __('C.N.I.C') }}</label>
<div class="col-md-6">
<input id="nic" type="text" class="form-control{{ $errors->has('nic') ? ' is-invalid' : '' }}" name="nic" value="{{ old('nic') }}" required autofocus>
@if ($errors->has('nic'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('nic') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group row">
<label for="name" class="col-md-4 col-form-label text-md-right">{{ __('Phone') }}</label>
<div class="col-md-6">
<input id="name" type="text" class="form-control{{ $errors->has('name') ? ' is-invalid' : '' }}" name="phone" value="{{ old('name') }}" required autofocus>
@if ($errors->has('name'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('name') }}</strong>
</span>
@endif
</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{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email') }}" required>
@if ($errors->has('email'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('email') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group row">
<label for="email" class="col-md-4 col-form-label text-md-right">{{ __('Official E-Mail') }}</label>
<div class="col-md-6">
<input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email') }}" required>
@if ($errors->has('email'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('off_email') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>
<div class="col-md-6">
<input id="password" type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" required>
@if ($errors->has('password'))
<span class="invalid-feedback" role="alert">
<strong>{{ $errors->first('password') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group row">
<label for="password-confirm" class="col-md-4 col-form-label text-md-right">{{ __('Confirm Password') }}</label>
<div class="col-md-6">
<input id="password-confirm" type="password" class="form-control" name="password_confirmation" required>
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Register') }}
</button>
<a href="{{url('auth/google')}}" class="btn btn-primary">Register With Google</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection
Модель является пользователем, и ее код указан ниже.
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'tname','fname','domicile','nic','phone','email','off_email', 'password'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}
Это код аутентификации./RegisterController.php
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
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 = '/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, [
'tname' => 'required|string|max:255',
'fname' => 'required|string|max:255',
'domicile' => 'required|string|max:255',
'nic' => 'required|string|max:255',
'phone' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'off_email' => 'required|string|email|max:255',
'password' => 'required|string|min:6|confirmed',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\User
*/
protected function create(array $data)
{
return User::create([
'tname' => $data['tname'],
'fname' => $data['fname'],
'domicile' => $data['domicile'],
'nic' => $data['nic'],
'phone' => $data['phone'],
'email' => $data['email'],
'off_email' => $data['off_email'],
'password' => Hash::make($data['password']),
]);
}
}
Форма не показывает каких-либо ошибок при отправке, она просто обновляет, нет сообщения, что данные вставлены или нет, в то время как при проверке таблицы пользователей не будет никакой строки, ..Любое тело может помочь мне, пожалуйста,