سلام و خسته نباشین
وقتی که آدرس http://127.0.0.1:8000/auth/email/send-verification رو تایپ میکنم ایمیل ارسال نمیشه و ارور میده
ارور به صورت Trying to access array offset on value of type null
هستش
ممنون میشم پاسخ بدین
user
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use App\Jobs\SendEmail;
use App\Mail\VerificationEmail;
use App\Mail\ResetPassword;
use App\Services\Auth\Traits\MagicallyAuthenticable;
use App\Services\Auth\Traits\HasTwoFactor;
class User extends Authenticatable
{
use Notifiable, MagicallyAuthenticable, HasTwoFactor;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password', 'phone_number', 'provider', 'provider_id', 'email_verified_at', 'avatar'
];
/**
* 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::dispatchNow($this,new VerificationEmail($this));
}
}
verificationController
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\VerifiesEmails;
use Illuminate\Support\Facades\Auth;
use League\OAuth1\Client\Server\Tumblr;
use Illuminate\Http\Request;
use Illuminate\Auth\Access\AuthorizationException;
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();
// dd(Auth::user());
//get user
//create signed route
//send url
// redirect
}
public function verify()
{
return 'dd';
}
}
verification email
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\User;
use Illuminate\Support\Facades\URL;
class VerificationEmail extends Mailable
{
use Queueable, SerializesModels;
private $user;
/**
* Create a new message instance.
*
* @return void
*/
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()->addMinute(120),['email'=>$this->user->email]);
}
}
web
<?php
/*
|--------------------------------------------------------------------------
| 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!
|
*/
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\URL;
Route::get('/',function (){
return view('welcome');
// $url=URL::temporarySignedRoute('test',now()->addMinute(60),['id'=>'12']);
// dd($url);
})->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.reg ster');
Route::get('login','loginController@showLoginForm')->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');
});
Route::get('test',function (){
return 'hi';
})->name('test');