| Server IP : 172.67.178.83 / Your IP : 216.73.217.141 Web Server : Apache System : Linux hosting01.arsenalhost.com 4.18.0-425.13.1.lve.el8.x86_64 #1 SMP Mon Feb 27 15:23:24 EST 2023 x86_64 User : corbizre ( 1013) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/corbizre/findnextproperty.com/frontend/components/ |
Upload File : |
<?php
namespace app\components;
use console\models\Housestable;
use yii\base\Widget;
use frontend\components\StateHelper;
class StateWidget extends Widget
{
public $countState;
public $model;
public function init()
{
parent::init();
$resultArray = array();
$listStates = Housestable::find()
->select('State')
->groupBy('State')
->all();
foreach ($listStates as $house){
$count = $this->getCount($house->State);
$name = StateHelper::getStateName($house->State);
if($count > 0 && $name != false) {
$resultArray[$name] = $count;
}
}
// $listStates = StateHelper::getStateWordsAsArray();
// for ($i = 1; $i <= $this->countState; $i++) {
// $randState = rand(1, 50);
// $ranStateName = $listStates[$randState];
// $count = $this->getCount($ranStateName);
// if($count != 0) {
// $resultArray[StateHelper::getStateName($ranStateName)] = $count;
// }
// }
$this->model = $resultArray;
}
public function run()
{
echo $this->render('state-widget',['model'=>$this->model]);
}
public function getCount($word){
$model = Housestable::getCountByState($word);
return $model;
}
}