|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- <?php
-
-
-
- namespace common\forms;
-
- use domain\Producer\Producer\Producer;
- use Yii;
- use yii\base\Model;
-
-
- class ContactForm extends Model
- {
-
- public $name;
- public $email;
- public $subject;
- public $body;
- public $verifyCode;
- public $isTest;
-
-
-
- public function rules()
- {
- return [
- [['name', 'email', 'subject', 'body'], 'required', 'message' => 'Champs obligatoire'],
- ['email', 'email', 'message' => 'Email incorrect'],
- ['isTest', 'string'],
- ['verifyCode', 'captcha', 'message' => 'Veuillez recopier le code de vérification', 'when' => function($model) {
- return $model->isTest != 'isTest';
- }],
- ];
- }
-
-
-
- public function attributeLabels()
- {
- return [
- 'name' => 'Nom',
- 'email' => 'Email',
- 'subject' => 'Sujet',
- 'body' => 'Message',
- 'verifyCode' => 'Code de vérification',
- ];
- }
-
-
-
- public function sendEmail(Producer $producer)
- {
- return Yii::$app->mailerService->sendProducer(
- $producer,
- 'Contact : ' . $this->subject,
- 'contact',
- [
- 'content' => $this->body,
- 'name' => $this->name,
- 'email' => $this->email
- ],
- $this->email
- );
- }
-
- public function sendEmailShopSupport(Producer $producer)
- {
- return Yii::$app->mailerService->sendAdmin(
- 'Support > '.$producer->name.' : ' . $this->subject,
- 'contact',
- [
- 'content' => $this->body,
- 'name' => $this->name,
- 'email' => $this->email
- ],
- $this->email
- );
- }
-
- public function sendEmailAdmin()
- {
- return Yii::$app->mailerService->sendAdmin(
- 'Contact : ' . $this->subject,
- 'contact',
- [
- 'content' => $this->body,
- 'name' => $this->name,
- 'email' => $this->email
- ],
- $this->email
- );
- }
- }
|