class AppointmentForm extends ActiveRecord
{
public $name;
public $email;
public $phone;
public $date;
public $body;
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'system_appointment';
}
/**
* @return array the validation rules.
*/
public function rules()
{
return [
// name, email, subject and body are required
[['name', 'email', 'phone', 'date', 'body'], 'required'],
// email has to be a valid email address
['email', 'email'],
];
}
/**
* Sends an email to the specified email address using the information collected by this model.
* @param string $email the target email address
* @return bool whether the model passes validation
*/
public function appointment($email)
{
$content = "<p>Email: " . $this->email . "</p>";
$content .= "<p>Name: " . $this->name . "</p>";
$content .= "<p>Phone: " . $this->phone . "</p>";
$content .= "<p>Date: " . $this->date . "</p>";
$content .= "<p>Body: " . $this->body . "</p>";
if ($this->validate()) {
Yii::$app->mailer->compose(["content" => $content])
->setTo('clinicpro@clinicpro.uz')
->setFrom([\Yii::$app->params['supportEmail'] => $this->name])
->setTextBody($this->body)
->send();
return true;
}
return false;
}
}
->setPhone($this->phone)
->setDate($this->date)
->setName($this->subject)
->setEmail($this->email)