|
|
@@ -2,6 +2,7 @@ |
|
|
|
namespace frontend\models; |
|
|
|
|
|
|
|
use common\models\User; |
|
|
|
use common\models\Etablissement; |
|
|
|
use yii\base\Model; |
|
|
|
use Yii; |
|
|
|
|
|
|
@@ -17,33 +18,25 @@ class SignupForm extends Model |
|
|
|
public $prenom; |
|
|
|
public $telephone; |
|
|
|
public $is_boulanger; |
|
|
|
|
|
|
|
public $siret; |
|
|
|
public $nom_magasin; |
|
|
|
|
|
|
|
public $code_postal; |
|
|
|
public $ville; |
|
|
|
|
|
|
|
/** |
|
|
|
* @inheritdoc |
|
|
|
*/ |
|
|
|
public function rules() |
|
|
|
{ |
|
|
|
return [ |
|
|
|
/*['username', 'filter', 'filter' => 'trim'], |
|
|
|
['username', 'required'], |
|
|
|
['username', 'unique', 'targetClass' => '\common\models\User', 'message' => 'Cet identifiant est déjà utilisé'], |
|
|
|
['username', 'string', 'min' => 2, 'max' => 255],*/ |
|
|
|
|
|
|
|
['email', 'filter', 'filter' => 'trim'], |
|
|
|
['email', 'required','message'=>'Champs obligatoire'], |
|
|
|
['email', 'email'], |
|
|
|
['email', 'unique', 'targetClass' => '\common\models\User', 'message' => 'Cet email est déjà utilisé'], |
|
|
|
|
|
|
|
['nom','required','message'=>'Champs obligatoire'], |
|
|
|
['nom', 'string', 'min' => 2, 'max' => 255], |
|
|
|
|
|
|
|
['prenom','required','message'=>'Champs obligatoire'], |
|
|
|
['prenom', 'string', 'min' => 2, 'max' => 255], |
|
|
|
|
|
|
|
['telephone','required','message'=>'Champs obligatoire'], |
|
|
|
['telephone', 'string', 'min' => 2, 'max' => 255, 'message'=>'Bada'], |
|
|
|
[['nom', 'prenom', 'telephone', 'ville', 'code_postal'],'required','message'=>'Champs obligatoire'], |
|
|
|
[['nom', 'prenom', 'telephone', 'ville', 'code_postal'], 'string', 'min' => 2, 'max' => 255], |
|
|
|
|
|
|
|
['password', 'required','message'=>'Champs obligatoire'], |
|
|
|
['password', 'string', 'min' => 6, 'tooShort' => 'Votre mot de passe doit contenir au moins 6 caractères'], |
|
|
@@ -111,7 +104,6 @@ class SignupForm extends Model |
|
|
|
{ |
|
|
|
if ($this->validate()) { |
|
|
|
$user = new User(); |
|
|
|
//$user->username = $this->username; |
|
|
|
$user->username = $this->email; |
|
|
|
$user->email = $this->email; |
|
|
|
$user->nom = $this->nom ; |
|
|
@@ -121,15 +113,20 @@ class SignupForm extends Model |
|
|
|
|
|
|
|
if($this->is_boulanger) |
|
|
|
{ |
|
|
|
$user->is_boulanger = 1 ; |
|
|
|
$user->nom_magasin = $this->nom_magasin ; |
|
|
|
$user->siret = $this->siret ; |
|
|
|
$etablissement = new Etablissement ; |
|
|
|
$etablissement->nom = $this->nom_magasin ; |
|
|
|
$etablissement->siret = $this->siret; |
|
|
|
$etablissement->code_postal = $this->code_postal; |
|
|
|
$etablissement->ville = $this->ville; |
|
|
|
$etablissement->save() ; |
|
|
|
|
|
|
|
$user->id_etablissement = $etablissement->id ; |
|
|
|
$user->status = User::STATUS_BOULANGER ; |
|
|
|
} |
|
|
|
|
|
|
|
$user->setPassword($this->password); |
|
|
|
$user->generateAuthKey(); |
|
|
|
if ($user->save()) { |
|
|
|
|
|
|
|
// envoi d'un mail de confirmation |
|
|
|
$message = "Bonjour, |
|
|
|
|
|
|
@@ -166,7 +163,9 @@ Matthieu" ; |
|
|
|
'telephone' => 'Téléphone', |
|
|
|
'is_boulanger' => "Je suis professionnel et souhaite mettre en place un système de réservation de pain dans ma boulangerie", |
|
|
|
'nom_magasin' => 'Nom de la boulangerie', |
|
|
|
'siret' => 'Numéro SIRET' |
|
|
|
'siret' => 'Numéro SIRET', |
|
|
|
'code_postal' => 'Code postal', |
|
|
|
'ville' => 'Commune' |
|
|
|
]; |
|
|
|
} |
|
|
|
} |