コード例 #1
0
ファイル: SendController.php プロジェクト: YGugnin/mailer
 public function actionIndex()
 {
     $model = new Mails();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('index', ['model' => $model]);
     }
 }
コード例 #2
0
ファイル: MailsController.php プロジェクト: YGugnin/mailer
 /**
  * Finds the Mails model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Mails the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Mails::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #3
0
ファイル: index.php プロジェクト: YGugnin/mailer
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Send Log';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="send-log-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <?php 
$list = \app\models\Mails::find()->all();
$mails = ArrayHelper::map($list, 'id', 'subject');
$list = \app\models\Users::find()->all();
$users = ArrayHelper::map($list, 'id', 'name');
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'rowOptions' => function ($model) {
    if (!$model->success) {
        return ['class' => 'danger'];
    }
}, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', ['attribute' => 'user_id', 'value' => function ($data) {
    return Html::a(Html::encode($data->user['name']), Url::to(['users/view', 'id' => $data->user_id]));
}, 'format' => 'raw', 'filter' => $users], ['attribute' => 'mail_id', 'value' => function ($data) {
    return Html::a(Html::encode($data->mail['subject']), Url::to(['mails/view', 'id' => $data->mail_id]));
}, 'format' => 'raw', 'filter' => $mails], ['attribute' => 'send_time', 'format' => 'date', 'filter' => \yii\jui\DatePicker::widget(['model' => $searchModel, 'attribute' => 'send_time', 'language' => 'en', 'dateFormat' => 'yyyy-MM-dd'])], ['attribute' => 'success', 'format' => 'boolean', 'filter' => [0 => 'No', 1 => 'Yes']], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{view}']]]);
?>

</div>
コード例 #4
0
ファイル: SendLog.php プロジェクト: YGugnin/mailer
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMail()
 {
     return $this->hasOne(Mails::className(), ['id' => 'mail_id']);
 }