static function distance($point1, $point2, $unit = 2 ) {
if (!$point2) return null;
if (!$point1) return null;
$point1 = explode(',', $point1);
$lon1 = $point1[0];
$lat1 = $point1[1];
$point2 = explode(',', $point2);
$lon2 = $point2[0];
$lat2 = $point2[1];
if ($lon1 == 0 || $lon2 == 0) {
return null;
}
$theta = $lon1 - $lon2;
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
switch ($unit) {
case(self::UNIT_KM) :
$out = $miles * 1.609344;
break;
case(self::UNIT_MI) :
$out = $miles;
break;
case(self::UNIT_NA) :
$out = $miles * 0.8684;
break;
}
return $out;
}
$response = [];
if ( have_posts() ){
while ( have_posts() ){
the_post();
$response['items'][]= 'elemnt';
}
}
T1::find()->andWhere(['id in ( select t2_id
from T2
where user_id = :user_id) ',['user_id'=>200]])->andWhere(['>', 'created_at', 0])->all()select t1.*,t2.t2_id
from T1
left join t2 on
t2.t1_id = t1.id
where created_at > 0 and t2.user_id=200T1::find()->leftJoin('t2','t2.t1_id = t1.id')->andWhere(['t2.user_id'=>'200'])->andWhere(['>', 'created_at', 0])->all()T1::find()->joinWith(['t2'])->andWhere(['t2.user_id'=>'200'])->andWhere(['>', 'created_at', 0])->all()
Model1::find()
->joinWith(['model2'])
->andWhere('model2.field is not null');
initRangeExpr = true;
pluginOptions['ranges'] = [
Yii::t('kvdrp', 'Today') => ["moment().startOf('day')", "moment().endOf('day')"],
Yii::t('kvdrp', 'Yesterday') => ["moment().startOf('day').subtract(1,'days')", "moment().endOf('day').subtract(1,'days')"],
Yii::t('kvdrp', 'Last {n} Days', ['n' => 7]) => ["moment().startOf('day').subtract(6, 'days')", "moment().endOf('day')"],
Yii::t('kvdrp', 'Last {n} Days', ['n' => 30]) => ["moment().startOf('day').subtract(29, 'days')", "moment().endOf('day')"],
Yii::t('kvdrp', 'This Month') => ["moment().startOf('month')", "moment().endOf('month')"],
Yii::t('kvdrp', 'Last Month') => ["moment().subtract(1, 'month').startOf('month')", "moment().subtract(1, 'month').endOf('month')"]
];