M
M
Mikha Pankratov2015-12-15 12:24:04
Yii
Mikha Pankratov, 2015-12-15 12:24:04

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']);

    }

Where am I wrong? And does hasMany write by hand at all?
error Call to a member function getAvailability() on a non-object

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Bukharev, 2015-12-15
@evgenybuckharev

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 question

Ask a Question

731 491 924 answers to any question