/** * @return \yii\db\ActiveQuery */ public function getCurrentLocation() { return $this->hasOne(LocationHistory::className(), ['package_id' => 'id'])->orderBy('timestamp DESC')->with('site')->groupBy('package_id'); }
public function getMaterials() { return $this->hasMany(LocationHistory::className(), ['site_id' => 'id'])->select('location_history.*')->innerJoin('package')->innerJoin('material'); }