سلام وقت بخیر
زمانی که پروژه لاراول ساختم هیچ تغیری در migration user ایجاد نکردم. خواستم که authentication راه اندازی کنم با دستور composer ایجاد کردم و فایل های کنترلر auth ایجاد شد ولی حالاکه فرم ثبت نام رو تو آدرس بار بالا سرچ میکنم ، فرم کامل باز میشه ولی وقتی save میزنم این خطا رو بهم میده
کد های کنترلر register
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use App\Models\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:2'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => ['required', 'string', 'min:8', 'confirmed'],
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\Models\User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
}
}
کدهای مدل user
<?php
namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
'email',
'password',
];
/**
* 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',
];
}
کد web.php
Auth::routes();
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
کدview register
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>register</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body dir="rtl" style="text-align: right">
@include('layouts.topmenu')
<div class="container">
@include('layouts.messages')
<div class="d-flex justify-content-center">
<form action="{{route('register')}}" method="POST">
@include('layouts.messages')
@csrf
<div class="form-group">
<label for="title">last name & first name: </label>
<input type="text" class="form-control @error('name') is-invalid @enderror" name="name">
@error('name')
<div class="alert alert-danger"> {{$message}}</div>
@enderror
</div>
<div class="form-group">
<label for="title">email: </label>
<input type="email" class="form-control @error('email') is-invalid @enderror" name="email">
@error('email')
<div class="alert alert-danger"> {{$message}}</div>
@enderror
</div>
<div class="form-group">
<label for="title"> password </label>
<input type="password" class="form-control @error('password') is-invalid @enderror" name="password">
@error('password')
<div class="alert alert-danger"> {{$message}}</div>
@enderror
</div>
<div class="form-group">
<label for="title"> verify password: </label>
<input type="password" class="form-control @error('password_confirmation') is-invalid @enderror" name="password_confirmation">
@error('password_confirmation')
<div class="alert alert-danger"> {{$message}}</div>
@enderror
</div>
<div class="form-group">
<label for="title"></label>
<button type="submit" class="btn btn-success">register</button>
</div>
</form>
</div>
</div>
</body>
</html>
خطایی که موقع زدن save میده
@khanzadimahdi
قبلاکار میکرد جدیدا اینجوری شده
کل فایل .env هم اینجوری هست
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:M/mmZMw/B7kdQ4lN4z6yjpfkx8PvllXUE1dXF2k2ytA=
APP_DEBUG=true
APP_URL=http://laravel.test
LOG_CHANNEL=stack
LOG_LEVEL=debug
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
MEMCACHED_HOST=memcached
REDIS_HOST=redis
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
آیا مایل به ارسال نوتیفیکیشن و اخبار از طرف راکت هستید ؟