Your IP : 216.73.216.79


Current Path : /var/www/html/sprm/backend/models/
Upload File :
Current File : /var/www/html/sprm/backend/models/KeratanAkhbar.php

<?php

namespace backend\models;

use Yii;

/**
 * This is the model class for table "keratan_akhbar".
 *
 * @property int $keratan_akhbar_id
 * @property string $keratan_akhbar_title_my
 * @property string $keratan_akhbar_title_en
 * @property string $keratan_akhbar_content_my
 * @property string $keratan_akhbar_content_en
 * @property string $keratan_akhbar_image
 * @property int $keratan_akhbar_status
 * @property string $keratan_akhbar_publish_date
 * @property string $keratan_akhbar_end_date
 * @property string $keratan_akhbar_url
 * @property int $keratan_akhbar_sorting
 * @property int $keratan_akhbar_hit_counter
 * @property string $created_at
 * @property string $created_by
 * @property string $updated_at
 * @property string $updated_by
 */
class KeratanAkhbar extends \common\models\Dermaga
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'keratan_akhbar';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['keratan_akhbar_content_my', 'keratan_akhbar_content_en'], 'string'],
            [['keratan_akhbar_status', 'keratan_akhbar_sorting', 'keratan_akhbar_hit_counter'], 'integer'],
            [['keratan_akhbar_publish_date', 'keratan_akhbar_end_date', 'created_at', 'updated_at'], 'safe'],
            [['keratan_akhbar_title_my', 'keratan_akhbar_title_en', 'created_by', 'updated_by'], 'string', 'max' => 300],
            [['keratan_akhbar_url'], 'string', 'max' => 500],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'keratan_akhbar_id' => Yii::t('app', 'Keratan Akhbar ID'),
            'keratan_akhbar_title_my' => Yii::t('app', 'Tajuk My'),
            'keratan_akhbar_title_en' => Yii::t('app', 'Tajuk En'),
            'keratan_akhbar_content_my' => Yii::t('app', 'Kandungan My'),
            'keratan_akhbar_content_en' => Yii::t('app', 'Kandungan En'),
            'keratan_akhbar_image' => Yii::t('app', 'Gambar Keratan Akhbar'),
            'keratan_akhbar_status' => Yii::t('app', 'Status Keratan Akhbar'),
            'keratan_akhbar_publish_date' => Yii::t('app', 'Tarikh Penerbitan'),
            'keratan_akhbar_end_date' => Yii::t('app', 'Tarikh Tamat'),
            'keratan_akhbar_url' => Yii::t('app', 'URL'),
            'keratan_akhbar_sorting' => Yii::t('app', 'Susunan'),
            'keratan_akhbar_hit_counter' => Yii::t('app', 'Hit Counter'),
            'created_at' => Yii::t('app', 'Created At'),
            'created_by' => Yii::t('app', 'Created By'),
            'updated_at' => Yii::t('app', 'Updated At'),
            'updated_by' => Yii::t('app', 'Updated By'),
        ];
    }
	    public function upload()
    {
        if ($this->validate()) {
            if ($this->validate()) {

                if($this->keratan_akhbar_image != NULL){
                    $this->keratan_akhbar_image->saveAs('uploads/' . $this->keratan_akhbar_image->baseName . date('dmyhi') . '.' . $this->keratan_akhbar_image->extension);
                     /* rewrite url path for uniquenes */
                    $this->keratan_akhbar_image = $this->keratan_akhbar_image->baseName . date('dmyhi') . '.' . $this->keratan_akhbar_image->extension;
                }
                return true;
            } else {
                return false;
            }
            return true;
        } else {
            return false;
        }
    }
}