Skip to content

Instantly share code, notes, and snippets.

@ydatech
Created October 2, 2016 12:50
Show Gist options
  • Select an option

  • Save ydatech/bc49cb3cc39ca364ce54d1f6e28212f4 to your computer and use it in GitHub Desktop.

Select an option

Save ydatech/bc49cb3cc39ca364ce54d1f6e28212f4 to your computer and use it in GitHub Desktop.
Model Provinsi
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "provinsi".
*
* @property integer $id
* @property string $nama
*
* @property Kota[] $kotas
*/
class Provinsi extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'provinsi';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['nama'], 'string', 'max' => 50],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'nama' => 'Nama',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getKota()
{
return $this->hasMany(Kota::className(), ['provinsi_id' => 'id']);
}
public function extraFields(){
return ['kota'];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment