Files
yii2/tests/data/ar/CustomerWithConstructor.php
Paul Klimov d68789a195 Fixes #13779, fixes #5786
- #13779: Fixed `yii\db\ActiveRecord::joinWith()` unable to use relation defined via attached behavior.
- #5786: Allowed to use custom constructors in ActiveRecord-based classes.
2017-08-29 15:13:28 +03:00

45 lines
970 B
PHP

<?php
namespace yiiunit\data\ar;
/**
* CustomerWithConstructor
*
* @property int $id
* @property string $name
* @property string $email
* @property string $address
* @property int $status
*
* @property ProfileWithConstructor $profile
*/
class CustomerWithConstructor extends ActiveRecord
{
public static function tableName()
{
return 'customer';
}
public function __construct($name, $email, $address)
{
$this->name = $name;
$this->email = $email;
$this->address = $address;
parent::__construct();
}
public static function instance($refresh = false)
{
return self::instantiate([]);
}
public static function instantiate($row)
{
return (new \ReflectionClass(static::className()))->newInstanceWithoutConstructor();
}
public function getProfile()
{
return $this->hasOne(ProfileWithConstructor::className(), ['id' => 'profile_id']);
}
}