سلام
از جلسه قبل مشکلی ندارم و ایمیل به یوزر در mailtrap ارسال میشود در این جلسه اومدیم متود verify ایجاد کردیم و یک dd گرفتیم.
مشکل ام این است وقتی در mailtrap روی دکمه کلیک میکنیم ارور میگه همچین آدرس ای وجود ندارد در حالی که همون آدرس را در مرور گر میزنم اون dd را نشان میدهد
لطفا راهنمایی کنید
آدرس
http://127.0.0.1:8000/Auth/email/verify?email=m.datkhah%40gmail.com&expires=1626003493&signature=b4c2cb8897ac334afe8f46cc714abf30038371363a21b06852e1b9187492c391
array:3 [▼
"email" => "m.datkhah@gmail.com"
"expires" => "1626003493"
"signature" => "b4c2cb8897ac334afe8f46cc714abf30038371363a21b06852e1b9187492c391"
]
web ام
<?php
use Illuminate\Support\Facades\Route;
use \Illuminate\Support\Facades\URL;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return view('welcome1');
})->name('home');
Route::group(['prefix'=>'Auth', 'namespace'=>'Auth'],function (){
Route::get('register','registerController@showRegistrationForm')->name('auth.register.form');
Route::post('register','registerController@register')->name('auth.register');
Route::get('login','LoginController@LoginForm')->name('auth.login.form');
Route::post('login','LoginController@Login')->name('auth.login');
Route::get('logout','LoginController@logout')->name('auth.logout');
Route::get('email/send-verification','verificationController@send')->name('auth.email.send.verification');
Route::get('email/verify','VerificationController@verify')->name('auth.email.verify');
});
VerificationController
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
use App\jobs;
use App\services\notifications\Providers\EmailProvider;
use Illuminate\Http\Request;
use Illuminate\Foundation\Auth\VerifiesEmails;
use Illuminate\Support\Facades\Auth;
class VerificationController extends Controller
{
/*
|--------------------------------------------------------------------------
| Email Verification Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling email verification for any
| user that recently registered with the application. Emails may also
| be re-sent if the user didn't receive the original email message.
|
*/
use VerifiesEmails;
/**
* Where to redirect users after verification.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
$this->middleware('signed')->only('verify');
$this->middleware('throttle:6,1')->only('verify', 'send');
}
public function send()
{
Auth::user()->sendEmailVerificationNotification();
return back()->with('verificationEmailSent',true);
}
public function verify(Request $request)
{
dd($request->all());
}
}
verificationEmail
<?php
namespace App\Mail;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\URL;
class verificationEmail extends Mailable
{
use Queueable, SerializesModels;
private $user;
/**
* Create a new message instance.
*
* @param User $user
*/
public function __construct( User $user)
{
$this->user=$user;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->markdown('emails.verification-email')->with([
'link'=>$this->generateUrl(),
'name'=>$this->user->name,
]);
}
protected function generateUrl(){
return URL::temporarySignedRoute('auth.email.verify',now()->addMinutes(120),['email'=>$this->user->email]);
}
}
user.php
<?php
namespace App;
use App\Jobs\sendEmail;
use App\Mail\verificationEmail;
use App\services\notifications\Providers\EmailProvider;
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 = [
'name', 'email', 'password','phone_number'
];
/**
* 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 sendEmailVerificationNotification()
{
sendEmail::dispatch($this,new verificationEmail($this));
}
}
sendEmail
<?php
namespace App\Jobs;
use App\Services\Notifications\Notification;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class sendEmail implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
private $user;
private $mailable;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(User $user,Mailable $mailable)
{
$this->user=$user;
$this->mailable=$mailable;
}
/**
* Execute the job.
*
* @return void
*/
public function handle(Notification $notification)
{
return $notification->sendEmail($this->user , $this->mailable) ;
}
}