Answer the question
In order to leave comments, you need to log in
How to make hasMany() d yii2?
Good afternoon,
I have 2 tables
user_availabilitie
'id', 'availability_id', 'is_active', 'days'
availabilitie
'id', 'from', 'to', 'days_id'
I write hasMany
public function getAvailabilitys()
{
return $this->hasMany(Availabilitie::className(), ['availability_id' => 'id']);
}
Answer the question
In order to leave comments, you need to log in
The essence of the error is that you are requesting the getAvailabilitys () method not from an object, first solve this issue, and then it will be seen whether the hasMany connection works or not.
Links are written manually, or via gii during automatic model generation, if the checkbox is checked during creation and if the link is set at the database level
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question