Skip to content

Instantly share code, notes, and snippets.

@RdeWilde
Last active October 19, 2016 09:42
Show Gist options
  • Save RdeWilde/014673eb08078342a72ab4cc7ec33913 to your computer and use it in GitHub Desktop.
Save RdeWilde/014673eb08078342a72ab4cc7ec33913 to your computer and use it in GitHub Desktop.
{
"name": "PHP Notice",
"message": "Undefined index: rental_id",
"code": 8,
"type": "yii\\base\\ErrorException",
"file": "\/var\/www\/vhosts\/domain.tld\/subdomains\/dev\/httpdocs\/folder\/api\/vendor\/yiisoft\/yii2\/db\/ActiveRelationTrait.php",
"line": 459,
"stack-trace": [
"#0 \/var\/www\/vhosts\/domain.tld\/subdomains\/dev\/httpdocs\/folder\/api\/vendor\/yiisoft\/yii2\/db\/ActiveRelationTrait.php(459): yii\\base\\ErrorHandler->handleError(8, 'Undefined index...', '\/var\/www\/vhosts...', 459, Array)",
"#1 \/var\/www\/vhosts\/domain.tld\/subdomains\/dev\/httpdocs\/folder\/api\/vendor\/yiisoft\/yii2\/db\/ActiveRelationTrait.php(217): yii\\db\\ActiveQuery->filterByModels(Array)",
"#2 \/var\/www\/vhosts\/domain.tld\/subdomains\/dev\/httpdocs\/folder\/api\/vendor\/yiisoft\/yii2\/db\/ActiveQueryTrait.php(174): yii\\db\\ActiveQuery->populateRelation('rentalType', Array)",
"#3 \/var\/www\/vhosts\/domain.tld\/subdomains\/dev\/httpdocs\/folder\/api\/vendor\/yiisoft\/yii2\/db\/ActiveQuery.php(215): yii\\db\\ActiveQuery->findWith(Array, Array)",
"#4 \/var\/www\/vhosts\/domain.tld\/subdomains\/dev\/httpdocs\/folder\/api\/vendor\/yiisoft\/yii2\/db\/Query.php(211): yii\\db\\ActiveQuery->populate(Array)",
"#5 \/var\/www\/vhosts\/domain.tld\/subdomains\/dev\/httpdocs\/folder\/api\/vendor\/yiisoft\/yii2\/db\/ActiveQuery.php(133): yii\\db\\Query->all(Object(yii\\db\\Connection))",
"#6 \/var\/www\/vhosts\/domain.tld\/subdomains\/dev\/httpdocs\/folder\/api\/vendor\/digizijn\/framework\/base\/ActiveQuery.php(191): yii\\db\\ActiveQuery->all(Object(yii\\db\\Connection))",
"#7 [internal function]: us\\base\\ActiveQuery->us\\base\\{closure}(Object(yii\\db\\Connection))",
"#8 \/var\/www\/vhosts\/domain.tld\/subdomains\/dev\/httpdocs\/folder\/api\/vendor\/yiisoft\/yii2\/db\/Connection.php(432): call_user_func(Object(Closure), Object(yii\\db\\Connection))",
"#9 \/var\/www\/vhosts\/domain.tld\/subdomains\/dev\/httpdocs\/folder\/api\/vendor\/digizijn\/framework\/base\/ActiveQuery.php(193): yii\\db\\Connection->cache(Object(Closure), 3600)",
"#10 \/var\/www\/vhosts\/domain.tld\/subdomains\/dev\/httpdocs\/folder\/api\/vendor\/digizijn\/framework\/base\/ActiveQuery.php(110): us\\base\\ActiveQuery->run('all', NULL, Object(yii\\db\\Connection))",
"#11 \/var\/www\/vhosts\/domain.tld\/subdomains\/dev\/httpdocs\/folder\/api\/vendor\/digizijn\/framework\/queries\/RecreationRentalPeriodQuery.php(79): us\\base\\ActiveQuery->all()",
"#12 \/var\/www\/vhosts\/domain.tld\/subdomains\/dev\/httpdocs\/folder\/api\/vendor\/digizijn\/framework\/models\/database\/RecreationEvents.php(861): app\\vendor\\digizijn\\framework\\queries\\RecreationRentalPeriodQuery->byAmountOfNights(Object(us\\models\\database\\RecreationObjectType), 1)",
"#13 \/var\/www\/vhosts\/domain.tld\/subdomains\/dev\/httpdocs\/folder\/api\/controllers\/RecreationBookingController.php(292): us\\models\\database\\RecreationEvents->setPeriodPrices()",
"#14 [internal function]: app\\controllers\\RecreationBookingController->actionPricing('52', '2017-01-01', '2017-01-28', 1, 21, 2)",
"#15 \/var\/www\/vhosts\/domain.tld\/subdomains\/dev\/httpdocs\/folder\/api\/vendor\/yiisoft\/yii2\/base\/InlineAction.php(55): call_user_func_array(Array, Array)",
"#16 \/var\/www\/vhosts\/domain.tld\/subdomains\/dev\/httpdocs\/folder\/api\/vendor\/yiisoft\/yii2\/base\/Controller.php(154): yii\\base\\InlineAction->runWithParams(Array)",
"#17 \/var\/www\/vhosts\/domain.tld\/subdomains\/dev\/httpdocs\/folder\/api\/vendor\/yiisoft\/yii2\/base\/Module.php(454): yii\\base\\Controller->runAction('pricing', Array)",
"#18 \/var\/www\/vhosts\/domain.tld\/subdomains\/dev\/httpdocs\/folder\/api\/vendor\/yiisoft\/yii2\/web\/Application.php(100): yii\\base\\Module->runAction('recreation-book...', Array)",
"#19 \/var\/www\/vhosts\/domain.tld\/subdomains\/dev\/httpdocs\/folder\/api\/vendor\/yiisoft\/yii2\/base\/Application.php(375): yii\\web\\Application->handleRequest(Object(yii\\web\\Request))",
"#20 \/var\/www\/vhosts\/domain.tld\/subdomains\/dev\/httpdocs\/folder\/api\/web\/index.php(40): yii\\base\\Application->run()",
"#21 {main}"
],
<?php
/**
* @property integer $object_id
* @property integer $type_id
* ...
*/
class RecreationObject extends \us\base\ActiveRecord implements Linkable, Filterable {
use Filtering;
/* .. */
public function getObjectType() {
return $this->hasOne(RecreationObjectType::className(), ['type_id' => 'type_id'])->inverseOf('objects');
}
/* .. */
}
<?php
/**
* @property integer $conn_id
* @property integer $object_id
* @property integer $rental_id
* ...
*/
class RecreationObjectRentalConnection extends \us\base\ActiveRecord {
/* .. */
public function getRentalType() {
return $this->hasOne(RecreationRentalType::className(), ['rental_id' => 'rental_id'])->inverseOf('rentalTypeConnection');
}
public function getObjects()
{
return $this->hasMany(RecreationObject::className(), ['object_id' => 'object_id'])->inverseOf('rentalConnection');
}
/* .. */
}
<?php
/**
* @property integer $type_id
* ...
*/
class RecreationObjectType extends \us\base\ActiveRecord implements Linkable, Filterable {
use Filtering;
/* .. */
public function getObjects() {
return $this->hasMany(RecreationObject::className(), ['type_id' => 'type_id'])->inverseOf('objectType');
}
/* .. */
}
<?php
/**
* @property integer $period_id
* @property integer $rental_id
* ...
*/
class RecreationRentalPeriod extends \us\base\ActiveRecord {
/* .. */
public function getRentalType() {
return $this->hasOne(RecreationRentalType::className(), ['rental_id' => 'rental_id'])->inverseOf('rentalPeriod');
}
/* .. */
}
<?php
/* ... */
class RecreationRentalPeriodQuery extends ActiveQuery {
/**
* @param RecreationObjectType $objectType
* @return static
*/
public function byObjectType(RecreationObjectType $objectType) {
return $this->innerJoinWith([
'rentalType.rentalTypeConnection.objects.objectType' => function($q) use ($objectType) {
$modelClass = $q->modelClass;
$q->andWhere([$modelClass::tableName().'.type_id' => $objectType->type_id]);
}]
);
}
public function byAmountOfNights(RecreationObjectType $objectType, $amountOfNights){
/* ... */
// TODO FIXME TODO FIXME TODO FIXME TODO FIXME TODO FIXME TODO FIXME
$allPeriods = RecreationRentalPeriod::find()->cache()
->select([
RecreationRentalPeriod::tableName().'.period_id',
//RecreationRentalType::tableName().'.rental_id',
//RecreationObjectRentalConnection::tableName().'.object_id',
//RecreationObject::tableName().'.object_id',
//RecreationObject::tableName().'.type_id',
//RecreationObjectType::tableName().'.type_id',
])
->byObjectType($objectType)->groupBy(RecreationRentalPeriod::tableName().'.period_id')->asArray()->all();
/* ... */
}
}
<?php
/**
* @property integer $rental_id
* ...
*/
class RecreationRentalType extends \us\base\ActiveRecord implements Linkable {
/* .. */
public function getRentalTypeConnection() {
return $this->hasMany(RecreationObjectRentalConnection::className(), ['rental_id' => 'rental_id'])->inverseOf('rentalType'); // TODO Resolve foreignKey ['rental_id' => 'rental_id']
}
/* .. */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment