Example #1
0
 public function beforeSave($insert)
 {
     $this->url = StringHelper::getTransliterateUrl($this->title);
     return parent::beforeSave($insert);
 }
Example #2
0
<?php 
if (count($data)) {
    ?>
    <?php 
    foreach ($data as $item) {
        ?>
    <dl>
        <dt>
        <h3><?php 
        echo $item->question;
        ?>
</h3>
        <div class="q-info"> <span class="author"><?php 
        echo \common\components\StringHelper::hideMiddle($item->username);
        ?>
咨询</span> <span class="time"><?php 
        echo Yii::$app->formatter->asDatetime($item->created_at);
        ?>
</span> </div>
        </dt>
        <dd> <em class="arrow"></em>
            <div class="ans-bd ans-nala cle">
                <div class="author">商城回复:</div>
                <div class="con">
                    <p><?php 
        echo $item->answer;
        ?>
</p>
                    <div class="time"><?php 
        echo Yii::$app->formatter->asDatetime($item->updated_at);
 public function up()
 {
     foreach ($this->data as $item) {
         $this->insert('category', ['title' => $item[0], 'url' => \common\components\StringHelper::getTransliterateUrl($item[0]), 'icon' => $item[1], 'icon_hover' => \yii\helpers\ArrayHelper::getValue($item, '4'), 'parent_id' => \yii\helpers\ArrayHelper::getValue($item, '2'), 'image' => \yii\helpers\ArrayHelper::getValue($item, '3')]);
     }
 }