本文整理汇总了PHP中Property::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Property::model方法的具体用法?PHP Property::model怎么用?PHP Property::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Property
的用法示例。
在下文中一共展示了Property::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveAndDeleteMedia
private function saveAndDeleteMedia($type)
{
/** @var $model Media [ ] */
$model = new Media();
$mockRecord = $this->getMockRecord();
$instruction = Deal::model()->findByPk($mockRecord['med_row']);
$this->assertNotEmpty($instruction, "instruction not exist");
$property = Property::model()->findByPk($instruction->dea_prop);
$this->assertNotEmpty($property, "property not exist");
$this->assertNotNull($property->addressId, "property has no address");
$address = Address::model()->findByPk($property->addressId);
$this->assertNotEmpty($address, " Address not exist");
$model->setAttributes($this->getMockRecord());
$model->file = $this->getMockCuploadedImage('image/jpeg', 1);
if ($type == Media::TYPE_PHOTO) {
$model->setCropFactor($this->getCropFactor());
} elseif ($type == Media::TYPE_EPC || $type == Media::TYPE_FLOORPLAN) {
$model->otherMedia = $type;
}
$this->assertTrue($model->validate(), "record not validated");
$this->assertTrue($model->save(), "record not saved");
foreach ($model->getImageSizes() as $imageSize) {
$this->assertFileExists($model->getFullPath($imageSize), $imageSize . " does not exist");
}
$this->deleteMedia($model->med_id);
}
示例2: testSetClientsSavesClientsAfterModelIsSaved
public function testSetClientsSavesClientsAfterModelIsSaved()
{
$model = $this->getModel('search');
$model->setClients([1, 2], Property::CLIENT_TYPE_TENANT);
$this->assertTrue(is_array($model->tenants));
$model->save(false);
$model = Property::model()->findByPk($model->pro_id);
$this->assertTrue(is_array($model->tenants));
$this->assertCount(2, $model->tenants);
}
示例3: actionIndex
public function actionIndex()
{
Yii::beginProfile('wishlist');
$criteria = PropertyWishlistApi::getCriteriaObjectForUser(Yii::app()->user->id);
$count = Property::model()->count($criteria);
$pages = new CPagination($count);
$pages->pageSize = Yii::app()->params['resultsPerPage'];
$pages->applyLimit($criteria);
$properties = PropertyWishlistApi::searchWithCriteria($criteria);
// $projects = ProjectWishlistApi::getWishlistProjectsByUserId(Yii::app()->user->id);
$this->render('index', array('properties' => $properties, 'count' => $count, 'pages' => $pages));
Yii::endProfile('wishlist');
}
示例4: getWishlistPropertiesByUserId
public static function getWishlistPropertiesByUserId($userId)
{
$models = Property::model()->findAllBySql("SELECT * FROM property where id IN(SELECT property_id FROM property_wishlist WHERE user_id=:userId)", array(':userId' => $userId));
$result = array();
if ($models) {
foreach ($models as $model) {
$result[] = $model;
}
return $result;
} else {
return false;
}
}
示例5: actionSimilar
public function actionSimilar($id)
{
Yii::beginProfile('requirements_view');
$session = Yii::app()->session;
$requirement = RequirementApi::getRequirementById($id);
if (!$requirement) {
throw new CHttpException(404, 'The requested page does not exist.');
}
$userDetails = UserApi::getUserProfileDetails($requirement->user_id);
$data['i_want_to'] = $requirement->i_want_to;
$data['min_price'] = $requirement->min_price;
$data['max_price'] = $requirement->max_price;
$propertytypes = RequirementPropertyTypesApi::getPropertyTypesByRequirementId($requirement->id);
$propertytypeids = null;
if ($propertytypes) {
foreach ($propertytypes as $propertytype) {
$propertytypeids[] = $propertytype->property_type_id;
}
}
$data['property_type_id'] = $propertytypeids;
$amenity_ids = RequirementAmenitiesApi::getAmenitiesByRequirementId($requirement->id);
$amenityids = null;
if ($amenity_ids) {
foreach ($amenity_ids as $amenity_id) {
$amenityids[] = $amenity_id->amenity_id;
}
}
$data['PropertyAmenities'] = $amenityids;
$cityids = RequirementCitiesApi::getCitiesByRequirementId($requirement->id);
$city = null;
if ($cityids) {
foreach ($cityids as $cityid) {
$city[] = $cityid->city_id;
}
}
$data['city_id'] = $city;
$bedrooms = RequirementBedroomsApi::getBedroomsByRequirementId($requirement->id);
$beds = null;
if ($bedrooms) {
foreach ($bedrooms as $bedroom) {
$beds[] = $bedroom->bedrooms;
}
}
$data['bedrooms'] = $beds;
$criteria = PropertyApi::getCriteriaObjectForRequirement($data);
$count = Property::model()->count($criteria);
$pages = new CPagination($count);
$pages->pageSize = Yii::app()->params['resultsPerPage'];
$pages->applyLimit($criteria);
$properties = PropertyApi::searchMyPropertyWithCriteria($criteria);
$this->render('similar', array('requirement' => $requirement, 'userDetails' => $userDetails, 'properties' => $properties, 'pages' => $pages, 'propertiesCount' => $count));
Yii::endProfile('requirements_view');
}
示例6: array
echo $form->labelEx($model, 'user_id');
?>
<?php
echo $form->dropDownList($model, 'user_id', UserApi::getUserList(), array('empty' => 'Select'));
?>
<?php
echo $form->error($model, 'user_id');
?>
</div>
<div class="row">
<?php
echo $form->labelEx($model, 'property_id');
?>
<?php
echo $form->dropDownList($model, 'property_id', CHtml::listData(Property::model()->findAll(), 'id', 'property_name'), array('empty' => 'Select'));
?>
<?php
echo $form->error($model, 'property_id');
?>
</div>
<div class="row">
<?php
echo $form->label($model, 'rate');
?>
<?php
echo $form->textField($model, 'rate');
?>
</div>
示例7: actionSearch
public function actionSearch()
{
Yii::beginProfile('search_property_and_people');
// Initiate the entities.
$properties = null;
$users = null;
$projects = null;
$data = null;
$data_user = null;
$data_project = null;
$data_user['user_type'] = 'agent';
$amenities = null;
$pages = null;
$pagesAgent = null;
$pagesBuilder = null;
$pagesSpecialists = null;
$pagesProject = null;
$criteria = PropertyApi::getCriteriaObject($data);
$totalProp = Property::model()->count();
$pages = new CPagination($totalProp);
$pages->pageSize = Yii::app()->params['resultsPerPage'];
$pages->applyLimit($criteria);
$properties = PropertyApi::searchPropertyWithCriteria($criteria);
$propertiesCount = $totalProp;
$totalUser = 0;
$criteria = UserApi::getCriteriaObject($data_user);
$users = UserApi::searchUser($data_user);
if ($users) {
$totalUser = count($users);
}
$pagesUser = new CPagination($totalUser);
$pagesUser->pageSize = Yii::app()->params['resultsPerPage'];
$pagesUser->applyLimit($criteria);
$users = UserApi::searchUserWithCriteria($criteria);
//$users = UserApi::searchUser($data_user);
$projects = ProjectApi::searchProject($data_project);
/* Property Model */
$modelProperty = new Property();
$modelState = new GeoState();
$modelCity = new GeoCity();
$propertyAmenities = new PropertyAmenities();
// echo '<pre>';var_dump($pages);die();
/* People Models */
$modelUser = new UserCredentials();
$modelProfile = new UserProfiles();
$modelSpecialistType = new UserSpecialistType();
/* Project Model */
$modelProject = new Projects();
$projectAmenities = new ProjectAmenities();
if (isset($_POST['search']) && isset($_POST['mode'])) {
if ($_POST['mode'] == "property") {
$modelProperty->attributes = $_POST['Property'];
//$modelProperty['i_want_to'] = isset($_POST['Property']['i_want_to'])?$_POST['Property']['i_want_to'] : null;
$data = $_POST['Property'];
$data['keyword'] = isset($_POST['keyword']) ? $_POST['keyword'] : null;
$data['city'] = $_POST['GeoCity']['city'];
$data['budget_min'] = $_POST['budget_min'];
$data['budget_max'] = $_POST['budget_max'];
$data['without_budget'] = isset($_POST['without_budget']) ? $_POST['without_budget'] : 0;
$data['PropertyAmenities'] = isset($_POST['amenity_id']) ? $_POST['amenity_id'] : null;
$data['posted_by_all'] = isset($_POST['posted_by_all']) ? $_POST['posted_by_all'] : 0;
$data['posted_by'] = isset($_POST['posted_by']) ? $_POST['posted_by'] : null;
$criteria = PropertyApi::getCriteriaObject($data);
$totalProp = Property::model()->count();
$pages = new CPagination($totalProp);
$pages->pageSize = Yii::app()->params['resultsPerPage'];
$pages->applyLimit($criteria);
$properties = PropertyApi::searchPropertyWithCriteria($criteria);
$propertiesCount = $totalProp;
//$properties = PropertyApi::searchProperty($data);
} elseif ($_POST['mode'] == "people") {
$modelProfile->attributes = $_POST['UserProfiles'];
$data_user = null;
$data_user = $_POST['UserProfiles'];
$data_user['user_type'] = $_POST['user_type'];
$data_user['property_type_id'] = isset($_POST['property_type_id']) ? $_POST['property_type_id'] : null;
$data_user['keyword'] = isset($_POST['keyword']) ? $_POST['keyword'] : null;
$data_user['specialist_type_id'] = isset($_POST['specialist_type_id']) ? $_POST['specialist_type_id'] : null;
//$users = UserApi::searchUser($data_user);
if ($_POST['user_type'] == "agent") {
$totalAgent = '0';
$criteria = AgentProfileApi::getCriteriaObject($data_user);
$users = AgentProfileApi::searchAgents($data_user);
if ($users) {
$totalAgent = count($users);
}
$pagesAgent = new CPagination($totalAgent);
$pagesAgent->pageSize = Yii::app()->params['resultsPerPage'];
$pagesAgent->applyLimit($criteria);
$users = AgentProfileApi::searchAgentWithCriteria($criteria);
// $users = AgentProfileApi::searchAgents($data_user);
}
if ($_POST['user_type'] == "builder") {
$totalBuilder = '0';
$criteria = BuilderProfileApi::getCriteriaObject($data_user);
$users = BuilderProfileApi::searchBuilderWithCriteria($criteria);
if ($users) {
$totalBuilder = count($users);
}
$pagesBuilder = new CPagination($totalBuilder);
//.........这里部分代码省略.........
示例8: getPropertyCount
public static function getPropertyCount($projectId)
{
$models = Property::model()->findAllBySql("SELECT * FROM property where id IN(SELECT property_id FROM project_properties WHERE project_id=:projectId)", array(':projectId' => $projectId));
$result = 0;
if ($models) {
$result = count($models);
}
return $result;
}
示例9: actionProperty
public function actionProperty()
{
Yii::beginProfile('search_property');
$session = new CHttpSession();
$session->open();
//$session->destroy();
//
// Initiate the pagination variables.
$properties = null;
$data = null;
//$data['new_launches'] = isset($_POST['new_launches']) ? $_POST['new_launches'] : '';
$data['new_launches'] = isset($_GET['new_launches']) ? $_GET['new_launches'] : '';
$data['agent_id'] = isset($_GET['agent_id']) ? $_GET['agent_id'] : '';
$data['builder_id'] = isset($_GET['builder_id']) ? $_GET['builder_id'] : '';
$data['i_want_to'] = isset($_GET['i_want_to']) ? $_GET['i_want_to'] : 'Sell';
// var_dump($data);die();
//var_dump($data);die();
// Initiate the models to be used in the search screen.
$modelProperty = new Property();
$modelState = new GeoState();
$modelCity = new GeoCity();
$modelLocality = new GeoLocality();
$propertyAmenities = new PropertyAmenities();
// var_dump(Yii::app()->params['resultsPerPage']);die();
// var_dump($_POST);
if (isset($_POST['Property'])) {
// Populate the search criteria to a variable and pass it to the Api to get the criteria object.
$modelProperty->attributes = $_POST['Property'];
$data = $_POST['Property'];
if (isset($_POST['minbuysearch'])) {
$data['property_type_id'] = '';
$data['transaction_type_id'] = '';
$data['age_of_construction'] = '';
$data['ownership_type_id'] = '';
$data['jackpot_investment'] = '0';
$data['featured'] = '0';
$data['instant_home'] = '0';
$data['keyword'] = '';
}
//$data['new_launches'] = isset($_POST['new_launches']) ? $_POST['new_launches'] : '';
$data['new_launches'] = isset($_GET['new_launches']) ? $_GET['new_launches'] : '';
$data['agent_id'] = isset($_GET['agent_id']) ? $_GET['agent_id'] : '';
$data['builder_id'] = isset($_GET['builder_id']) ? $_GET['builder_id'] : '';
$data['keyword'] = isset($_POST['keyword']) ? $_POST['keyword'] : null;
$data['city_id'] = isset($_POST['GeoCity']['city']) ? $_POST['GeoCity']['city'] : '';
$data['state_id'] = isset($_POST['GeoState']['state']) ? $_POST['GeoState']['state'] : '';
$data['locality_id'] = isset($_POST['GeoLocality']['locality']) ? $_POST['GeoLocality']['locality'] : '';
if ($data['locality_id'] != '') {
$locality = GeoLocality::model()->find('locality=:locality', array(':locality' => $data['locality_id']));
if ($locality) {
$data['locality_id'] = $locality->id;
}
}
if ($data['keyword'] = 'Eg: Builder') {
$data['keyword'] = '';
}
//var_dump($_POST['Property']['i_want_to']);
if (isset($_POST['Property']['i_want_to'])) {
if ($_POST['Property']['i_want_to'] == 'Rent') {
if (isset($_POST['budget_min_rent'])) {
$data['budget_min'] = $_POST['budget_min_rent'];
} elseif (isset($_POST['budget_min'])) {
$data['budget_min'] = $_POST['budget_min'];
}
if (isset($_POST['budget_max_rent'])) {
$data['budget_max'] = $_POST['budget_max_rent'];
} elseif (isset($_POST['budget_max'])) {
$data['budget_max'] = $_POST['budget_max'];
}
} else {
if (isset($_POST['budget_min'])) {
$data['budget_min'] = $_POST['budget_min'];
}
if (isset($_POST['budget_max'])) {
$data['budget_max'] = $_POST['budget_max'];
}
}
} else {
$data['i_want_to'] = 'sell';
if (isset($_POST['budget_min'])) {
$data['budget_min'] = $_POST['budget_min'];
}
if (isset($_POST['budget_max'])) {
$data['budget_max'] = $_POST['budget_max'];
}
}
$data['without_budget'] = isset($_POST['without_budget']) ? $_POST['without_budget'] : 0;
$data['PropertyAmenities'] = isset($_POST['PropertyAmenities']['amenity_id']) ? $_POST['PropertyAmenities']['amenity_id'] : null;
$data['posted_by_all'] = isset($_POST['posted_by_all']) ? $_POST['posted_by_all'] : 0;
$data['posted_by'] = isset($_POST['posted_by']) ? $_POST['posted_by'] : null;
$criteria = PropertyApi::getCriteriaObject($data);
$total = Property::model()->count($criteria);
$pages = new CPagination($total);
$pages->pageSize = Yii::app()->params['resultsPerPage'];
$pages->applyLimit($criteria);
$properties = PropertyApi::searchPropertyWithCriteria($criteria);
$propertiesCount = $total;
$session['search-criteria-property'] = $criteria;
$session['results-page'] = $total;
} else {
//.........这里部分代码省略.........
示例10: copyAs
/**
* makes a full copy of an instruction
*
* @param string $type
* @param string $status
* @return bool|\Deal
* @throws InvalidArgumentException
*/
public function copyAs($type = self::TYPE_SALES, $status = self::STATUS_PRODUCTION)
{
if (!in_array($type, [self::TYPE_LETTINGS, self::TYPE_SALES])) {
throw new InvalidArgumentException('type must be one of the following [' . self::TYPE_LETTINGS . ', ' . self::TYPE_SALES . '] actual value is: ' . $type);
}
if (!in_array($status, self::getStatuses())) {
throw new InvalidArgumentException('Status must be in the list [' . implode(', ', self::getStatuses()) . '] actual value is: ' . $status);
}
/** @var $property Property */
$property = Property::model()->findByPk($this->dea_prop);
$instruction = new Deal('copy');
$instruction->setAttributes($this->attributes);
$instruction->dea_type = $type;
$instruction->dea_status = $status;
$instruction->dea_marketprice = 0;
$instruction->dea_launchdate = null;
$instruction->importFromProperty($property);
if ($instruction->save(false)) {
InstructionVideo::copyRecords($this->dea_id, $instruction->dea_id);
LinkInstructionToFeature::copyRecords($this->dea_id, $instruction->dea_id);
LinkClientToInstruction::copyRecords($this->dea_id, $instruction->dea_id);
Media::copyRecords($this->dea_id, $instruction->dea_id);
return $instruction;
}
return false;
}
示例11: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return Property the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model = Property::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
$model->strArrayImagenes = $model->imagesToStringArray();
return $model;
}
示例12: loadModel
private function loadModel($id = null)
{
if ($id === null) {
$model = new Property();
} else {
$model = Property::model()->findByPk($id);
if (!$model) {
throw new CHttpException('404', 'Proeprty [id: ' . $id . '] not found');
}
}
if (isset($_GET['addressId']) && $_GET['addressId']) {
$address = Address::model()->findByPk($_GET['addressId']);
if ($address) {
$model->address = $address;
$model->addressId = $address->id;
}
}
if (isset($_GET['owner']) && $_GET['owner']) {
$model->setClients([$_GET['owner']], Property::CLIENT_TYPE_OWNER);
}
if (isset($_GET['tenant']) && $_GET['tenant']) {
$model->setClients([$_GET['tenant']], Property::CLIENT_TYPE_TENANT);
}
return $model;
}
示例13: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer the ID of the model to be loaded
*/
public function loadModel($id)
{
$model = Property::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例14: actionSelectInstruction
public function actionSelectInstruction()
{
$builder = AppointmentBuilder::getCurrent();
if (isset($_POST['Deal']) && $_POST['Deal']) {
// need to finish instruction info;
$instruction = Deal::model()->findByPk($builder->getInstructionId());
$instruction->attributes = $_POST['Deal'];
if ($instruction->save()) {
$this->redirect(['InstructionSelected', 'instructionId' => $instruction->dea_id]);
} else {
echo "<pre style='color:blue' title='" . __FILE__ . "'>" . basename(__FILE__) . ":" . __LINE__ . "<br>";
print_r($instruction->getErrors());
echo "</pre>";
}
$this->render('createInstruction', ['model' => $instruction]);
return;
}
/** @var $property Property */
$property = Property::model()->findByPk($builder->getPropertyId());
if (!$property->instructions || isset($_GET['new'])) {
// need to create one.
$instruction = new Deal();
$instruction->dea_prop = $property->pro_id;
$instruction->dea_status = Deal::STATUS_VALUATION;
$instruction->importFromProperty($property);
$instruction->save(false);
$builder->setInstructionId($instruction->dea_id);
$this->render('createInstruction', ['model' => $instruction]);
return;
}
$this->render('selectInstruction', ['model' => $property]);
}
示例15: actionUpdate
public function actionUpdate($id, $imageId = '')
{
// var_dump($_GET);die();
Yii::beginProfile('property_update');
$model = Property::model()->findByPk($id);
if (!$model) {
throw new CHttpException(404, 'The requested page does not exist.');
}
$jackpot = $model->jackpot_investment;
$instant = $model->instant_home;
$currentImages = PropertyImagesApi::getAllImages($model->id);
$localitymodel = GeoLocality::model()->find('id=:id', array(':id' => $model->locality_id));
$locality = $localitymodel->locality;
if ($imageId && is_array($currentImages)) {
$imageResult = false;
if (array_key_exists($imageId, $currentImages)) {
$imageResult = PropertyImagesApi::deleteImageByPk($imageId);
}
$this->renderPartial('_imageDeleted', array('result' => $imageResult));
Yii::app()->end();
}
if ($model->user_id != Yii::app()->user->id) {
throw new CHttpException(503, 'Unauthorized.');
}
// Open session object
$session = new CHttpSession();
$session->open();
$userId = Yii::app()->user->id;
$model->country = 'india';
$modelCity = new GeoCity();
$propertyAmenities = new PropertyAmenities();
$propertyImages = new PropertyImages();
$amenities = PropertyAmenitiesApi::getAmenitiesIdForProperty($id);
$localityNew = false;
if ($model->latitude && $model->longitude) {
$locationPosition = array($model->latitude, $model->longitude);
} else {
$locationPosition = array(20.59368, 78.96288);
}
$localityList = GeoLocalityApi::getAllNameList();
$this->performAjaxValidation($model);
//$this->performAjaxValidation($profilesModel);
if (isset($_POST['ajax']) && $_POST['ajax'] === 'property-form') {
echo CActiveForm::validate($model);
//echo CActiveForm::validate($profilesModel);
Yii::app()->end();
}
if (isset($_POST['submit'])) {
$amenity_id = array();
$model->attributes = $_POST['Property'];
$amenity_id = array();
if (isset($_POST['PropertyAmenitiesHouse']) && isset($_POST['PropertyAmenitiesExternal'])) {
$amenity_id = array_merge($_POST['PropertyAmenitiesHouse'], $_POST['PropertyAmenitiesExternal']);
} elseif (isset($_POST['PropertyAmenitiesHouse'])) {
$amenity_id = $_POST['PropertyAmenitiesHouse'];
} elseif (isset($_POST['PropertyAmenitiesExternal'])) {
$amenity_id = $_POST['PropertyAmenitiesExternal'];
}
// var_dump($amenity_id);die();
$model->user_id = $userId;
$valid = true;
$data = $_POST['Property'];
if (isset($model->city_id)) {
$cityModel = GeoCity::model()->findByPk($model->city_id);
if ($cityModel) {
$model->state_id = $cityModel->state_id;
$data['state_id'] = $cityModel->state_id;
if (isset($model->locality)) {
$criteria = new CDbCriteria();
$criteria->condition = 'city_id=:city_id && locality=:locality';
$criteria->params = array(':city_id' => $cityModel->id, ':locality' => $model->locality);
$localityModel = GeoLocality::model()->find($criteria);
$locality = $model->locality;
if ($localityModel) {
$model->locality_id = $localityModel->id;
} else {
$localityModel = new GeoLocality();
$localityModel->locality = $model->locality;
$localityModel->city_id = $model->city_id;
$localityModel->save();
$model->locality_id = $localityModel->id;
$localityNew = $localityModel;
}
$data['locality_id'] = $localityModel->id;
}
}
}
$valid = $valid && $model->validate();
if ($model->latitude != '' && $model->longitude != '') {
$locationPosition = array($model->latitude, $model->longitude);
}
if (!isset($data['property_type_id'])) {
$data['property_type_id'] = $model->property_type_id;
}
if ($valid) {
$data['property_name'] = PropertyTypesApi::getPropertyTypeById($data['property_type_id']);
if ($data['jackpot_investment'] != $jackpot) {
$data['jackpot_investment'] = 2;
}
if ($data['instant_home'] != $instant) {
//.........这里部分代码省略.........