Closed thiagotalma closed 9 months ago
Use the real name of the table to create the relationship when there is a composite primary key.
Prevents the generation of random relationship names.
Turn this:
<?php (...) /** * * @property int $id * @property int $employee_id * * @property Employee $employee * @property Route $employee0 <--- */ class Company extends \yii\db\ActiveRecord { (...) /** * Gets query for [[Employee]]. * * @return \yii\db\ActiveQuery */ public function getEmployee() { return $this->hasOne(Employee::class, ['id' => 'employee_id']); } /** * Gets query for [[Employee0]]. <--- * * @return \yii\db\ActiveQuery */ public function getEmployee0() /* <--- */ { return $this->hasOne(Route::class, ['employee_id' => 'employee_id', 'id' => 'route_id']); } }
Into this:
<?php (...) /** * * @property int $id * @property int $employee_id * @property string $route_id * * @property Employee $employee * @property Route $route <--- */ class Company extends \yii\db\ActiveRecord { (...) /** * Gets query for [[Employee]]. * * @return \yii\db\ActiveQuery */ public function getEmployee() { return $this->hasOne(Employee::class, ['id' => 'employee_id']); } /** * Gets query for [[Route]]. <--- * * @return \yii\db\ActiveQuery */ public function getRoute() /* <--- */ { return $this->hasOne(Route::class, ['employee_id' => 'employee_id', 'id' => 'route_id']); } }
Use the real name of the table to create the relationship when there is a composite primary key.
Prevents the generation of random relationship names.
Turn this:
Into this: