Answer the question
In order to leave comments, you need to log in
Using stubs for activeQuery queries?
how can i fix this code
$book = $this->getBookingOptions()->indexBy('session')->all();
public function getBookingOptions()
{
return $this->hasMany(BookingOption::className(), ['booking_id' => 'id']);
}
$this->bookingCount=Stub::make($this->bookingCount,['getBookingOptions'=>new BookingOption]);
[yii\base\UnknownMethodException] Calling unknown method: app\models\BookingOption::indexBy
Answer the question
In order to leave comments, you need to log in
You didn’t even get into the method signature, smoke the dock
. I guess
something like
$booking = Stub::make('Booking', [
'getBookingOptions' => function () { return [new BookingOption()]; }
]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question