I am trying to set-up a email verification in my laravel 8 project, I have used auth commmand to setup mu authentication in my project. The error that I am getting is:-
Missing required parameters for [Route: verification.verify] [URI: email/verify/{id}].
Here's my HomeController:-
public function __construct()
{
$this->middleware(['auth', 'verified']);
}
Here's my web.php:- (I do have more routes)
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\ConfessionsController;
use App\Http\Controllers\FriendsController;
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Route::get('/home', [HomeController::class, 'index'])->name('home');
//Confessions
Route::get('/confessions', [ConfessionsController::class, 'index'])->name('confession.index');
Route::get('/c/c/{id}', [ConfessionsController::class, 'create'])->name('confession.create');
Route::post('/confessions/created/{id}', [ConfessionsController::class, 'post'])->name('confession.store')->middleware('confessions');
Route::get('/confessions/delete/{id}', [ConfessionsController::class, 'destroy'])->name('confession.destroy');
//friends
Route::post('/confessions/add/{id}', [FriendsController::class, 'store'])->name('friend.store')->middleware('friends');
By reading this solution I edited my routes to this:-
use App\Http\Controllers\Auth\VerificationController;```
Auth::routes();
Route::get('email/verify', [VerificationController::class,'show'])->name('verification.notice');
Route::get('email/verify/{id}', [VerificationController::class,'verify'])->name('verification.verify');
Route::get('email/resend', [VerificationController::class, 'resend'])->name('verification.resend');
but still I got the same error.
Here's My .env :-
MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=MyUsername
MAIL_PASSWORD=MyPassword
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=MyEmailAddress
MAIL_FROM_NAME="${APP_NAME}"
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;
use App\Models\Concerns\UsesUuid;
use App\Models\Confession;
use Webpatser\Uuid\Uuid;
use Cache;
class User extends Authenticatable implements MustVerifyEmail
{
use HasFactory, Notifiable;
protected $guarded = []; // YOLO
public $incrementing = false;
protected $keyType = 'string';
protected static function boot()
{
parent::boot();
self::creating(function ($user) {
$user->uuid = (string) Uuid::generate(4);
});
}
}
UPDATE:-
I have added protected $primaryKey="uuid";
in my User Model and now as I hit register I don't get any error as well as no email but as I hit click here to request another
I get this error:-
The POST method is not supported for this route. Supported methods: GET, HEAD.
Auth::routes(['verify' => true]);
– Onur Demir