Bonjour,
s'il vous plait je suis débutant en laravel , j'ai creé un projet laravel 5.2.27
je suis en train de faire une validation d'inscription par mail avec un Event
mais je comprends pas quoi passer en parametre , voici mon code
class RegsiterConfirmation extends Event
{
use SerializesModels;
public $user;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct( User $user)
{
$this->user=$user;
}
/**
* Get the channels the event should be broadcast on.
*
* @return array
*/
public function broadcastOn()
{
return [];
}
}
class EmailConfirmation
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param RegsiterConfirmation $event
* @return void
*/
public function handle(RegsiterConfirmation $event)
{
$user=$event->user;
$email=$user->email;
\Mail::send('emails.welcom',,array('name'=>$user->name),function($message) use ($email) {
$message->to( $email,'mail Confirmation')->subject('mail Confirmation') ;
});
}
}
et ça le code du controlleur
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
use App\Events\RegsiterConfirmation ;
class AuthController extends Controller
{
/*
|--------------------------------------------------------------------------
| Registration & Login Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users, as well as the
| authentication of existing users. By default, this controller uses
| a simple trait to add these behaviors. Why don't you explore it?
|
*/
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
/**
* Where to redirect users after login / registration.
*
* @var string
*/
protected $redirectTo = '/';
/**
* Create a new authentication controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware($this->guestMiddleware(), ['except' => 'logout']);
}
/**
* 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|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|confirmed',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
// Event::fire(new RegsiterConfirmation() ;
}
// Event::fire(new RegsiterConfirmation(create()) ) ;
}
Décrivez ici ce que vous cherchez à obtenir
Décrivez ici vos erreurs ou ce que vous obtenez à la place de ce que vous attendez :(