| ... | ... |
@@ -153,7 +153,7 @@ class RealEstateAssetsModel extends Model |
| 153 | 153 |
$time = Date::floorToMinute(); |
| 154 | 154 |
$arrColumns[] = "$t.published='1' AND ($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'$time')"; |
| 155 | 155 |
} |
| 156 |
-dump(func_get_args()); |
|
| 156 |
+ |
|
| 157 | 157 |
return static::findOneBy($arrColumns, array($varId), $arrOptions); |
| 158 | 158 |
} |
| 159 | 159 |
|
| ... | ... |
@@ -153,8 +153,8 @@ class RealEstateAssetsModel extends Model |
| 153 | 153 |
$time = Date::floorToMinute(); |
| 154 | 154 |
$arrColumns[] = "$t.published='1' AND ($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'$time')"; |
| 155 | 155 |
} |
| 156 |
- |
|
| 157 |
- return static::findOneBy($arrColumns, $varId, $arrOptions); |
|
| 156 |
+dump(func_get_args()); |
|
| 157 |
+ return static::findOneBy($arrColumns, array($varId), $arrOptions); |
|
| 158 | 158 |
} |
| 159 | 159 |
|
| 160 | 160 |
/** |
| ... | ... |
@@ -194,11 +194,13 @@ class RealEstateAssetsModel extends Model |
| 194 | 194 |
|
| 195 | 195 |
if (isset($arrOptions['column'])) |
| 196 | 196 |
{
|
| 197 |
- $arrColumns = array_merge($arrColumns,$arrOptions['column']); |
|
| 197 |
+ $arrColumns = array_merge($arrColumns,array_values($arrOptions['column'])); |
|
| 198 |
+ unset($arrOptions['column']); |
|
| 198 | 199 |
} |
| 199 | 200 |
if (isset($arrOptions['value'])) |
| 200 | 201 |
{
|
| 201 |
- $arrValues = array_merge($arrValues,$arrOptions['value']); |
|
| 202 |
+ $arrValues = array_merge($arrValues,array_values($arrOptions['value'])); |
|
| 203 |
+ unset($arrOptions['value']); |
|
| 202 | 204 |
} |
| 203 | 205 |
|
| 204 | 206 |
return static::findBy($arrColumns, $arrValues, $arrOptions); |
| ... | ... |
@@ -231,13 +233,14 @@ class RealEstateAssetsModel extends Model |
| 231 | 233 |
|
| 232 | 234 |
if (isset($arrOptions['column'])) |
| 233 | 235 |
{
|
| 234 |
- $arrColumns = array_merge($arrColumns,$arrOptions['column']); |
|
| 236 |
+ $arrColumns = array_merge($arrColumns,array_values($arrOptions['column'])); |
|
| 237 |
+ unset($arrOptions['column']); |
|
| 235 | 238 |
} |
| 236 | 239 |
if (isset($arrOptions['value'])) |
| 237 | 240 |
{
|
| 238 |
- $arrValues = array_merge($arrValues,$arrOptions['value']); |
|
| 241 |
+ $arrValues = array_merge($arrValues,array_values($arrOptions['value'])); |
|
| 242 |
+ unset($arrOptions['value']); |
|
| 239 | 243 |
} |
| 240 |
- |
|
| 241 | 244 |
return static::countBy($arrColumns, $arrValues, $arrOptions); |
| 242 | 245 |
} |
| 243 | 246 |
} |
| ... | ... |
@@ -221,6 +221,7 @@ class RealEstateAssetsModel extends Model |
| 221 | 221 |
|
| 222 | 222 |
$t = static::$strTable; |
| 223 | 223 |
$arrColumns = ["$t.pid IN(" . implode(',', array_map('\intval', $arrPids)) . ")"];
|
| 224 |
+ $arrValues = []; |
|
| 224 | 225 |
|
| 225 | 226 |
if (!static::isPreviewMode($arrOptions)) |
| 226 | 227 |
{
|
| ... | ... |
@@ -228,6 +229,15 @@ class RealEstateAssetsModel extends Model |
| 228 | 229 |
$arrColumns[] = "$t.published='1' AND ($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'$time')"; |
| 229 | 230 |
} |
| 230 | 231 |
|
| 231 |
- return static::countBy($arrColumns, null, $arrOptions); |
|
| 232 |
+ if (isset($arrOptions['column'])) |
|
| 233 |
+ {
|
|
| 234 |
+ $arrColumns = array_merge($arrColumns,$arrOptions['column']); |
|
| 235 |
+ } |
|
| 236 |
+ if (isset($arrOptions['value'])) |
|
| 237 |
+ {
|
|
| 238 |
+ $arrValues = array_merge($arrValues,$arrOptions['value']); |
|
| 239 |
+ } |
|
| 240 |
+ |
|
| 241 |
+ return static::countBy($arrColumns, $arrValues, $arrOptions); |
|
| 232 | 242 |
} |
| 233 | 243 |
} |
| ... | ... |
@@ -45,179 +45,189 @@ use Contao\Model\Collection; |
| 45 | 45 |
* @property string|integer $start |
| 46 | 46 |
* @property string|integer $stop |
| 47 | 47 |
* |
| 48 |
- * @method static RealEstateAssetsModel|null findById($id, array $opt=array()) |
|
| 49 |
- * @method static RealEstateAssetsModel|null findByPk($id, array $opt=array()) |
|
| 50 |
- * @method static RealEstateAssetsModel|null findOneBy($col, $val, array $opt=array()) |
|
| 51 |
- * @method static RealEstateAssetsModel|null findOneByPid($val, array $opt=array()) |
|
| 52 |
- * @method static RealEstateAssetsModel|null findOneByTstamp($val, array $opt=array()) |
|
| 53 |
- * @method static RealEstateAssetsModel|null findOneByTitle($val, array $opt=array()) |
|
| 54 |
- * @method static RealEstateAssetsModel|null findOneByAddress($val, array $opt=array()) |
|
| 55 |
- * @method static RealEstateAssetsModel|null findOneByAssetNo($val, array $opt=array()) |
|
| 56 |
- * @method static RealEstateAssetsModel|null findOneByLivingSpace($val, array $opt=array()) |
|
| 57 |
- * @method static RealEstateAssetsModel|null findOneByNumberOfRooms($val, array $opt=array()) |
|
| 58 |
- * @method static RealEstateAssetsModel|null findOneByColdRent($val, array $opt=array()) |
|
| 59 |
- * @method static RealEstateAssetsModel|null findOneByAdvanceOperatingCosts($val, array $opt=array()) |
|
| 60 |
- * @method static RealEstateAssetsModel|null findOneByCondition($val, array $opt=array()) |
|
| 61 |
- * @method static RealEstateAssetsModel|null findOneByConstructionYear($val, array $opt=array()) |
|
| 62 |
- * @method static RealEstateAssetsModel|null findOneByCooperativeShares($val, array $opt=array()) |
|
| 63 |
- * @method static RealEstateAssetsModel|null findOneByFeatures($val, array $opt=array()) |
|
| 64 |
- * @method static RealEstateAssetsModel|null findOneByHeatingType($val, array $opt=array()) |
|
| 65 |
- * @method static RealEstateAssetsModel|null findOneByEnergyConsumption($val, array $opt=array()) |
|
| 66 |
- * @method static RealEstateAssetsModel|null findOneByGallerySRC($val, array $opt=array()) |
|
| 67 |
- * @method static RealEstateAssetsModel|null findOneByFloorPlansSRC($val, array $opt=array()) |
|
| 68 |
- * @method static RealEstateAssetsModel|null findOneByAvailability($val, array $opt=array()) |
|
| 69 |
- * @method static RealEstateAssetsModel|null findOneByAvailableFrom($val, array $opt=array()) |
|
| 70 |
- * @method static RealEstateAssetsModel|null findOneByDescription($val, array $opt=array()) |
|
| 71 |
- * @method static RealEstateAssetsModel|null findOneByPublished($val, array $opt=array()) |
|
| 72 |
- * @method static RealEstateAssetsModel|null findOneByStart($val, array $opt=array()) |
|
| 73 |
- * @method static RealEstateAssetsModel|null findOneByStop($val, array $opt=array()) |
|
| 48 |
+ * @method static RealEstateAssetsModel|null findById($id, array $opt = array()) |
|
| 49 |
+ * @method static RealEstateAssetsModel|null findByPk($id, array $opt = array()) |
|
| 50 |
+ * @method static RealEstateAssetsModel|null findOneBy($col, $val, array $opt = array()) |
|
| 51 |
+ * @method static RealEstateAssetsModel|null findOneByPid($val, array $opt = array()) |
|
| 52 |
+ * @method static RealEstateAssetsModel|null findOneByTstamp($val, array $opt = array()) |
|
| 53 |
+ * @method static RealEstateAssetsModel|null findOneByTitle($val, array $opt = array()) |
|
| 54 |
+ * @method static RealEstateAssetsModel|null findOneByAddress($val, array $opt = array()) |
|
| 55 |
+ * @method static RealEstateAssetsModel|null findOneByAssetNo($val, array $opt = array()) |
|
| 56 |
+ * @method static RealEstateAssetsModel|null findOneByLivingSpace($val, array $opt = array()) |
|
| 57 |
+ * @method static RealEstateAssetsModel|null findOneByNumberOfRooms($val, array $opt = array()) |
|
| 58 |
+ * @method static RealEstateAssetsModel|null findOneByColdRent($val, array $opt = array()) |
|
| 59 |
+ * @method static RealEstateAssetsModel|null findOneByAdvanceOperatingCosts($val, array $opt = array()) |
|
| 60 |
+ * @method static RealEstateAssetsModel|null findOneByCondition($val, array $opt = array()) |
|
| 61 |
+ * @method static RealEstateAssetsModel|null findOneByConstructionYear($val, array $opt = array()) |
|
| 62 |
+ * @method static RealEstateAssetsModel|null findOneByCooperativeShares($val, array $opt = array()) |
|
| 63 |
+ * @method static RealEstateAssetsModel|null findOneByFeatures($val, array $opt = array()) |
|
| 64 |
+ * @method static RealEstateAssetsModel|null findOneByHeatingType($val, array $opt = array()) |
|
| 65 |
+ * @method static RealEstateAssetsModel|null findOneByEnergyConsumption($val, array $opt = array()) |
|
| 66 |
+ * @method static RealEstateAssetsModel|null findOneByGallerySRC($val, array $opt = array()) |
|
| 67 |
+ * @method static RealEstateAssetsModel|null findOneByFloorPlansSRC($val, array $opt = array()) |
|
| 68 |
+ * @method static RealEstateAssetsModel|null findOneByAvailability($val, array $opt = array()) |
|
| 69 |
+ * @method static RealEstateAssetsModel|null findOneByAvailableFrom($val, array $opt = array()) |
|
| 70 |
+ * @method static RealEstateAssetsModel|null findOneByDescription($val, array $opt = array()) |
|
| 71 |
+ * @method static RealEstateAssetsModel|null findOneByPublished($val, array $opt = array()) |
|
| 72 |
+ * @method static RealEstateAssetsModel|null findOneByStart($val, array $opt = array()) |
|
| 73 |
+ * @method static RealEstateAssetsModel|null findOneByStop($val, array $opt = array()) |
|
| 74 | 74 |
* |
| 75 |
- * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByPid($val, array $opt=array()) |
|
| 76 |
- * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByTstamp($val, array $opt=array()) |
|
| 77 |
- * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByTitle($val, array $opt=array()) |
|
| 78 |
- * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByAddress($val, array $opt=array()) |
|
| 79 |
- * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByAssetNo($val, array $opt=array()) |
|
| 80 |
- * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByLivingSpace($val, array $opt=array()) |
|
| 81 |
- * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByNumberOfRooms($val, array $opt=array()) |
|
| 82 |
- * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByColdRent($val, array $opt=array()) |
|
| 83 |
- * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByAdvanceOperatingCosts($val, array $opt=array()) |
|
| 84 |
- * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByCondition($val, array $opt=array()) |
|
| 85 |
- * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByConstructionYear($val, array $opt=array()) |
|
| 86 |
- * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByCooperativeShares($val, array $opt=array()) |
|
| 87 |
- * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByFeatures($val, array $opt=array()) |
|
| 88 |
- * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByHeatingType($val, array $opt=array()) |
|
| 89 |
- * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByEnergyConsumption($val, array $opt=array()) |
|
| 90 |
- * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByGallerySRC($val, array $opt=array()) |
|
| 91 |
- * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByFloorPlansSRC($val, array $opt=array()) |
|
| 92 |
- * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByAvailability($val, array $opt=array()) |
|
| 93 |
- * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByAvailableFrom($val, array $opt=array()) |
|
| 94 |
- * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByDescription($val, array $opt=array()) |
|
| 95 |
- * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByPublished($val, array $opt=array()) |
|
| 96 |
- * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByStart($val, array $opt=array()) |
|
| 97 |
- * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByStop($val, array $opt=array()) |
|
| 98 |
- * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findMultipleByIds($val, array $opt=array()) |
|
| 99 |
- * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findBy($col, $val, array $opt=array()) |
|
| 100 |
- * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findAll(array $opt=array()) |
|
| 75 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByPid($val, array $opt = array()) |
|
| 76 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByTstamp($val, array $opt = array()) |
|
| 77 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByTitle($val, array $opt = array()) |
|
| 78 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByAddress($val, array $opt = array()) |
|
| 79 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByAssetNo($val, array $opt = array()) |
|
| 80 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByLivingSpace($val, array $opt = array()) |
|
| 81 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByNumberOfRooms($val, array $opt = array()) |
|
| 82 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByColdRent($val, array $opt = array()) |
|
| 83 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByAdvanceOperatingCosts($val, array $opt = array()) |
|
| 84 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByCondition($val, array $opt = array()) |
|
| 85 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByConstructionYear($val, array $opt = array()) |
|
| 86 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByCooperativeShares($val, array $opt = array()) |
|
| 87 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByFeatures($val, array $opt = array()) |
|
| 88 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByHeatingType($val, array $opt = array()) |
|
| 89 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByEnergyConsumption($val, array $opt = array()) |
|
| 90 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByGallerySRC($val, array $opt = array()) |
|
| 91 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByFloorPlansSRC($val, array $opt = array()) |
|
| 92 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByAvailability($val, array $opt = array()) |
|
| 93 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByAvailableFrom($val, array $opt = array()) |
|
| 94 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByDescription($val, array $opt = array()) |
|
| 95 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByPublished($val, array $opt = array()) |
|
| 96 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByStart($val, array $opt = array()) |
|
| 97 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByStop($val, array $opt = array()) |
|
| 98 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findMultipleByIds($val, array $opt = array()) |
|
| 99 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findBy($col, $val, array $opt = array()) |
|
| 100 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findAll(array $opt = array()) |
|
| 101 | 101 |
* |
| 102 |
- * @method static integer countById($id, array $opt=array()) |
|
| 103 |
- * @method static integer countByPid($val, array $opt=array()) |
|
| 104 |
- * @method static integer countByTstamp($val, array $opt=array()) |
|
| 105 |
- * @method static integer countByTitle($val, array $opt=array()) |
|
| 106 |
- * @method static integer countByAddress($val, array $opt=array()) |
|
| 107 |
- * @method static integer countByAssetNo($val, array $opt=array()) |
|
| 108 |
- * @method static integer countByLivingSpace($val, array $opt=array()) |
|
| 109 |
- * @method static integer countByNumberOfRooms($val, array $opt=array()) |
|
| 110 |
- * @method static integer countByColdRent($val, array $opt=array()) |
|
| 111 |
- * @method static integer countByAdvanceOperatingCosts($val, array $opt=array()) |
|
| 112 |
- * @method static integer countByCondition($val, array $opt=array()) |
|
| 113 |
- * @method static integer countByConstructionYear($val, array $opt=array()) |
|
| 114 |
- * @method static integer countByCooperativeShares($val, array $opt=array()) |
|
| 115 |
- * @method static integer countByFeatures($val, array $opt=array()) |
|
| 116 |
- * @method static integer countByHeatingType($val, array $opt=array()) |
|
| 117 |
- * @method static integer countByEnergyConsumption($val, array $opt=array()) |
|
| 118 |
- * @method static integer countByGallerySRC($val, array $opt=array()) |
|
| 119 |
- * @method static integer countByFloorPlansSRC($val, array $opt=array()) |
|
| 120 |
- * @method static integer countByAvailability($val, array $opt=array()) |
|
| 121 |
- * @method static integer countByAvailableFrom($val, array $opt=array()) |
|
| 122 |
- * @method static integer countByDescription($val, array $opt=array()) |
|
| 123 |
- * @method static integer countByPublished($val, array $opt=array()) |
|
| 124 |
- * @method static integer countByStart($val, array $opt=array()) |
|
| 125 |
- * @method static integer countByStop($val, array $opt=array()) |
|
| 102 |
+ * @method static integer countById($id, array $opt = array()) |
|
| 103 |
+ * @method static integer countByPid($val, array $opt = array()) |
|
| 104 |
+ * @method static integer countByTstamp($val, array $opt = array()) |
|
| 105 |
+ * @method static integer countByTitle($val, array $opt = array()) |
|
| 106 |
+ * @method static integer countByAddress($val, array $opt = array()) |
|
| 107 |
+ * @method static integer countByAssetNo($val, array $opt = array()) |
|
| 108 |
+ * @method static integer countByLivingSpace($val, array $opt = array()) |
|
| 109 |
+ * @method static integer countByNumberOfRooms($val, array $opt = array()) |
|
| 110 |
+ * @method static integer countByColdRent($val, array $opt = array()) |
|
| 111 |
+ * @method static integer countByAdvanceOperatingCosts($val, array $opt = array()) |
|
| 112 |
+ * @method static integer countByCondition($val, array $opt = array()) |
|
| 113 |
+ * @method static integer countByConstructionYear($val, array $opt = array()) |
|
| 114 |
+ * @method static integer countByCooperativeShares($val, array $opt = array()) |
|
| 115 |
+ * @method static integer countByFeatures($val, array $opt = array()) |
|
| 116 |
+ * @method static integer countByHeatingType($val, array $opt = array()) |
|
| 117 |
+ * @method static integer countByEnergyConsumption($val, array $opt = array()) |
|
| 118 |
+ * @method static integer countByGallerySRC($val, array $opt = array()) |
|
| 119 |
+ * @method static integer countByFloorPlansSRC($val, array $opt = array()) |
|
| 120 |
+ * @method static integer countByAvailability($val, array $opt = array()) |
|
| 121 |
+ * @method static integer countByAvailableFrom($val, array $opt = array()) |
|
| 122 |
+ * @method static integer countByDescription($val, array $opt = array()) |
|
| 123 |
+ * @method static integer countByPublished($val, array $opt = array()) |
|
| 124 |
+ * @method static integer countByStart($val, array $opt = array()) |
|
| 125 |
+ * @method static integer countByStop($val, array $opt = array()) |
|
| 126 | 126 |
* |
| 127 | 127 |
* @author Benjamin Roth <https://www.vonrotenberg.de> |
| 128 | 128 |
*/ |
| 129 | 129 |
class RealEstateAssetsModel extends Model |
| 130 | 130 |
{
|
| 131 | 131 |
|
| 132 |
- /** |
|
| 133 |
- * Table name |
|
| 134 |
- * @var string |
|
| 135 |
- */ |
|
| 136 |
- protected static $strTable = 'tl_vr_real_estate_assets'; |
|
| 137 |
- |
|
| 138 |
- /** |
|
| 139 |
- * Find a published assets from one or more categories |
|
| 140 |
- * |
|
| 141 |
- * @param mixed $varId The numeric id or alias name |
|
| 142 |
- * @param array $arrOptions An optional options array |
|
| 143 |
- * |
|
| 144 |
- * @return RealEstateAssetsModel|null A model or null if there is no asset |
|
| 145 |
- */ |
|
| 146 |
- public static function findPublishedByIdOrAlias($varId, array $arrOptions=array()) |
|
| 147 |
- {
|
|
| 148 |
- $t = static::$strTable; |
|
| 149 |
- $arrColumns = !preg_match('/^[1-9]\d*$/', $varId) ? array("BINARY $t.alias=?") : array("$t.id=?");
|
|
| 150 |
- |
|
| 151 |
- if (!static::isPreviewMode($arrOptions)) |
|
| 132 |
+ /** |
|
| 133 |
+ * Table name |
|
| 134 |
+ * @var string |
|
| 135 |
+ */ |
|
| 136 |
+ protected static $strTable = 'tl_vr_real_estate_assets'; |
|
| 137 |
+ |
|
| 138 |
+ /** |
|
| 139 |
+ * Find a published assets from one or more categories |
|
| 140 |
+ * |
|
| 141 |
+ * @param mixed $varId The numeric id or alias name |
|
| 142 |
+ * @param array $arrOptions An optional options array |
|
| 143 |
+ * |
|
| 144 |
+ * @return RealEstateAssetsModel|null A model or null if there is no asset |
|
| 145 |
+ */ |
|
| 146 |
+ public static function findPublishedByIdOrAlias($varId, array $arrOptions = array()) |
|
| 152 | 147 |
{
|
| 153 |
- $time = Date::floorToMinute(); |
|
| 154 |
- $arrColumns[] = "$t.published='1' AND ($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'$time')"; |
|
| 155 |
- } |
|
| 148 |
+ $t = static::$strTable; |
|
| 149 |
+ $arrColumns = !preg_match('/^[1-9]\d*$/', $varId) ? array("BINARY $t.alias=?") : array("$t.id=?");
|
|
| 156 | 150 |
|
| 157 |
- return static::findOneBy($arrColumns, $varId, $arrOptions); |
|
| 158 |
- } |
|
| 159 |
- |
|
| 160 |
- /** |
|
| 161 |
- * Find a published assets from one or more categories |
|
| 162 |
- * |
|
| 163 |
- * @param array $arrPids An array of parent IDs |
|
| 164 |
- * @param integer $intLimit An optional limit |
|
| 165 |
- * @param integer $intOffset An optional offset |
|
| 166 |
- * @param array $arrOptions An optional options array |
|
| 167 |
- * |
|
| 168 |
- * @return Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null A collection of models or null if there are no assets |
|
| 169 |
- */ |
|
| 170 |
- public static function findPublishedByParent($arrPids, $intLimit=0, $intOffset=0, array $arrOptions=array()) |
|
| 171 |
- {
|
|
| 172 |
- if (empty($arrPids) || !\is_array($arrPids)) |
|
| 173 |
- {
|
|
| 174 |
- return null; |
|
| 175 |
- } |
|
| 176 |
- |
|
| 177 |
- $t = static::$strTable; |
|
| 178 |
- $arrColumns = ["$t.pid IN(" . implode(',', array_map('\intval', $arrPids)) . ")"];
|
|
| 179 |
- |
|
| 180 |
- if (!static::isPreviewMode($arrOptions)) |
|
| 181 |
- {
|
|
| 182 |
- $time = Date::floorToMinute(); |
|
| 183 |
- $arrColumns[] = "$t.published='1' AND ($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'$time')"; |
|
| 151 |
+ if (!static::isPreviewMode($arrOptions)) |
|
| 152 |
+ {
|
|
| 153 |
+ $time = Date::floorToMinute(); |
|
| 154 |
+ $arrColumns[] = "$t.published='1' AND ($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'$time')"; |
|
| 155 |
+ } |
|
| 156 |
+ |
|
| 157 |
+ return static::findOneBy($arrColumns, $varId, $arrOptions); |
|
| 184 | 158 |
} |
| 185 | 159 |
|
| 186 |
- if (!isset($arrOptions['order'])) |
|
| 160 |
+ /** |
|
| 161 |
+ * Find a published assets from one or more categories |
|
| 162 |
+ * |
|
| 163 |
+ * @param array $arrPids An array of parent IDs |
|
| 164 |
+ * @param integer $intLimit An optional limit |
|
| 165 |
+ * @param integer $intOffset An optional offset |
|
| 166 |
+ * @param array $arrOptions An optional options array |
|
| 167 |
+ * |
|
| 168 |
+ * @return Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null A collection of models or null if there are no assets |
|
| 169 |
+ */ |
|
| 170 |
+ public static function findPublishedByParent($arrPids, $intLimit = 0, $intOffset = 0, array $arrOptions = array()) |
|
| 187 | 171 |
{
|
| 188 |
- $arrOptions['order'] = "FIELD($t.pid,".implode(',',$arrPids)."), $t.title ASC, $t.livingSpace ASC";
|
|
| 172 |
+ if (empty($arrPids) || !\is_array($arrPids)) |
|
| 173 |
+ {
|
|
| 174 |
+ return null; |
|
| 175 |
+ } |
|
| 176 |
+ |
|
| 177 |
+ $t = static::$strTable; |
|
| 178 |
+ $arrColumns = ["$t.pid IN(" . implode(',', array_map('\intval', $arrPids)) . ")"];
|
|
| 179 |
+ $arrValues = []; |
|
| 180 |
+ |
|
| 181 |
+ if (!static::isPreviewMode($arrOptions)) |
|
| 182 |
+ {
|
|
| 183 |
+ $time = Date::floorToMinute(); |
|
| 184 |
+ $arrColumns[] = "$t.published='1' AND ($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'$time')"; |
|
| 185 |
+ } |
|
| 186 |
+ |
|
| 187 |
+ if (!isset($arrOptions['order'])) |
|
| 188 |
+ {
|
|
| 189 |
+ $arrOptions['order'] = "FIELD($t.pid," . implode(',', $arrPids) . "), $t.title ASC, $t.livingSpace ASC";
|
|
| 190 |
+ } |
|
| 191 |
+ |
|
| 192 |
+ $arrOptions['limit'] = $intLimit; |
|
| 193 |
+ $arrOptions['offset'] = $intOffset; |
|
| 194 |
+ |
|
| 195 |
+ if (isset($arrOptions['column'])) |
|
| 196 |
+ {
|
|
| 197 |
+ $arrColumns = array_merge($arrColumns,$arrOptions['column']); |
|
| 198 |
+ } |
|
| 199 |
+ if (isset($arrOptions['value'])) |
|
| 200 |
+ {
|
|
| 201 |
+ $arrValues = array_merge($arrValues,$arrOptions['value']); |
|
| 202 |
+ } |
|
| 203 |
+ |
|
| 204 |
+ return static::findBy($arrColumns, $arrValues, $arrOptions); |
|
| 189 | 205 |
} |
| 190 | 206 |
|
| 191 |
- $arrOptions['limit'] = $intLimit; |
|
| 192 |
- $arrOptions['offset'] = $intOffset; |
|
| 193 |
- |
|
| 194 |
- return static::findBy($arrColumns, null, $arrOptions); |
|
| 195 |
- } |
|
| 196 |
- |
|
| 197 |
- /** |
|
| 198 |
- * Find a published assets from one or more categories |
|
| 199 |
- * |
|
| 200 |
- * @param array $arrPids An array of parent IDs |
|
| 201 |
- * @param array $arrOptions An optional options array |
|
| 202 |
- * |
|
| 203 |
- * @return integer The number of matching rows |
|
| 204 |
- */ |
|
| 205 |
- public static function countPublishedByParent($arrPids, array $arrOptions=array()) |
|
| 206 |
- {
|
|
| 207 |
- if (empty($arrPids) || !\is_array($arrPids)) |
|
| 207 |
+ /** |
|
| 208 |
+ * Find a published assets from one or more categories |
|
| 209 |
+ * |
|
| 210 |
+ * @param array $arrPids An array of parent IDs |
|
| 211 |
+ * @param array $arrOptions An optional options array |
|
| 212 |
+ * |
|
| 213 |
+ * @return integer The number of matching rows |
|
| 214 |
+ */ |
|
| 215 |
+ public static function countPublishedByParent($arrPids, array $arrOptions = array()) |
|
| 208 | 216 |
{
|
| 209 |
- return 0; |
|
| 210 |
- } |
|
| 217 |
+ if (empty($arrPids) || !\is_array($arrPids)) |
|
| 218 |
+ {
|
|
| 219 |
+ return 0; |
|
| 220 |
+ } |
|
| 211 | 221 |
|
| 212 |
- $t = static::$strTable; |
|
| 213 |
- $arrColumns = ["$t.pid IN(" . implode(',', array_map('\intval', $arrPids)) . ")"];
|
|
| 222 |
+ $t = static::$strTable; |
|
| 223 |
+ $arrColumns = ["$t.pid IN(" . implode(',', array_map('\intval', $arrPids)) . ")"];
|
|
| 214 | 224 |
|
| 215 |
- if (!static::isPreviewMode($arrOptions)) |
|
| 216 |
- {
|
|
| 217 |
- $time = Date::floorToMinute(); |
|
| 218 |
- $arrColumns[] = "$t.published='1' AND ($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'$time')"; |
|
| 219 |
- } |
|
| 225 |
+ if (!static::isPreviewMode($arrOptions)) |
|
| 226 |
+ {
|
|
| 227 |
+ $time = Date::floorToMinute(); |
|
| 228 |
+ $arrColumns[] = "$t.published='1' AND ($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'$time')"; |
|
| 229 |
+ } |
|
| 220 | 230 |
|
| 221 |
- return static::countBy($arrColumns, null, $arrOptions); |
|
| 222 |
- } |
|
| 231 |
+ return static::countBy($arrColumns, null, $arrOptions); |
|
| 232 |
+ } |
|
| 223 | 233 |
} |
| ... | ... |
@@ -138,15 +138,15 @@ class RealEstateAssetsModel extends Model |
| 138 | 138 |
/** |
| 139 | 139 |
* Find a published assets from one or more categories |
| 140 | 140 |
* |
| 141 |
- * @param int $intId The id of |
|
| 142 |
- * @param array $arrOptions An optional options array |
|
| 141 |
+ * @param mixed $varId The numeric id or alias name |
|
| 142 |
+ * @param array $arrOptions An optional options array |
|
| 143 | 143 |
* |
| 144 | 144 |
* @return RealEstateAssetsModel|null A model or null if there is no asset |
| 145 | 145 |
*/ |
| 146 |
- public static function findPublishedById(int $intId, array $arrOptions=array()) |
|
| 146 |
+ public static function findPublishedByIdOrAlias($varId, array $arrOptions=array()) |
|
| 147 | 147 |
{
|
| 148 | 148 |
$t = static::$strTable; |
| 149 |
- $arrColumns = array("$t.id=?");
|
|
| 149 |
+ $arrColumns = !preg_match('/^[1-9]\d*$/', $varId) ? array("BINARY $t.alias=?") : array("$t.id=?");
|
|
| 150 | 150 |
|
| 151 | 151 |
if (!static::isPreviewMode($arrOptions)) |
| 152 | 152 |
{
|
| ... | ... |
@@ -154,7 +154,7 @@ class RealEstateAssetsModel extends Model |
| 154 | 154 |
$arrColumns[] = "$t.published='1' AND ($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'$time')"; |
| 155 | 155 |
} |
| 156 | 156 |
|
| 157 |
- return static::findOneBy($arrColumns, $intId, $arrOptions); |
|
| 157 |
+ return static::findOneBy($arrColumns, $varId, $arrOptions); |
|
| 158 | 158 |
} |
| 159 | 159 |
|
| 160 | 160 |
/** |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,225 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+/** |
|
| 4 |
+ * OBG Customizations |
|
| 5 |
+ * |
|
| 6 |
+ * Copyright (c) 2021 vonRotenberg |
|
| 7 |
+ * |
|
| 8 |
+ * @license commercial |
|
| 9 |
+ */ |
|
| 10 |
+ |
|
| 11 |
+namespace vonRotenberg\RealEstateListingBundle\Model; |
|
| 12 |
+ |
|
| 13 |
+use Contao\CoreBundle\File\ModelMetadataTrait; |
|
| 14 |
+use Contao\Date; |
|
| 15 |
+use Contao\Model; |
|
| 16 |
+use Contao\Model\Collection; |
|
| 17 |
+ |
|
| 18 |
+/** |
|
| 19 |
+ * Reads and writes assets |
|
| 20 |
+ * |
|
| 21 |
+ * @property string|integer $id |
|
| 22 |
+ * @property string|integer $pid |
|
| 23 |
+ * @property string|integer $tstamp |
|
| 24 |
+ * @property string $title |
|
| 25 |
+ * @property string $address |
|
| 26 |
+ * @property string $assetNo |
|
| 27 |
+ * @property string|float $livingSpace |
|
| 28 |
+ * @property string|integer $numberOfRooms |
|
| 29 |
+ * @property string|float $coldRent |
|
| 30 |
+ * @property string|float $advanceOperatingCosts |
|
| 31 |
+ * @property string $condition |
|
| 32 |
+ * @property string $constructionYear |
|
| 33 |
+ * @property string|integer|null $cooperativeShares |
|
| 34 |
+ * @property string|null $features |
|
| 35 |
+ * @property string| $heatingType |
|
| 36 |
+ * @property string|float $energyConsumption |
|
| 37 |
+ * @property string|null $gallerySRC |
|
| 38 |
+ * @property string|null $orderSRC |
|
| 39 |
+ * @property string|null $floorPlansSRC |
|
| 40 |
+ * @property string|null $floorPlansOrderSRC |
|
| 41 |
+ * @property string $availability |
|
| 42 |
+ * @property string|integer $availableFrom |
|
| 43 |
+ * @property string|null $description |
|
| 44 |
+ * @property string|boolean $published |
|
| 45 |
+ * @property string|integer $start |
|
| 46 |
+ * @property string|integer $stop |
|
| 47 |
+ * |
|
| 48 |
+ * @method static RealEstateAssetsModel|null findById($id, array $opt=array()) |
|
| 49 |
+ * @method static RealEstateAssetsModel|null findByPk($id, array $opt=array()) |
|
| 50 |
+ * @method static RealEstateAssetsModel|null findOneBy($col, $val, array $opt=array()) |
|
| 51 |
+ * @method static RealEstateAssetsModel|null findOneByPid($val, array $opt=array()) |
|
| 52 |
+ * @method static RealEstateAssetsModel|null findOneByTstamp($val, array $opt=array()) |
|
| 53 |
+ * @method static RealEstateAssetsModel|null findOneByTitle($val, array $opt=array()) |
|
| 54 |
+ * @method static RealEstateAssetsModel|null findOneByAddress($val, array $opt=array()) |
|
| 55 |
+ * @method static RealEstateAssetsModel|null findOneByAssetNo($val, array $opt=array()) |
|
| 56 |
+ * @method static RealEstateAssetsModel|null findOneByLivingSpace($val, array $opt=array()) |
|
| 57 |
+ * @method static RealEstateAssetsModel|null findOneByNumberOfRooms($val, array $opt=array()) |
|
| 58 |
+ * @method static RealEstateAssetsModel|null findOneByColdRent($val, array $opt=array()) |
|
| 59 |
+ * @method static RealEstateAssetsModel|null findOneByAdvanceOperatingCosts($val, array $opt=array()) |
|
| 60 |
+ * @method static RealEstateAssetsModel|null findOneByCondition($val, array $opt=array()) |
|
| 61 |
+ * @method static RealEstateAssetsModel|null findOneByConstructionYear($val, array $opt=array()) |
|
| 62 |
+ * @method static RealEstateAssetsModel|null findOneByCooperativeShares($val, array $opt=array()) |
|
| 63 |
+ * @method static RealEstateAssetsModel|null findOneByFeatures($val, array $opt=array()) |
|
| 64 |
+ * @method static RealEstateAssetsModel|null findOneByHeatingType($val, array $opt=array()) |
|
| 65 |
+ * @method static RealEstateAssetsModel|null findOneByEnergyConsumption($val, array $opt=array()) |
|
| 66 |
+ * @method static RealEstateAssetsModel|null findOneByGallerySRC($val, array $opt=array()) |
|
| 67 |
+ * @method static RealEstateAssetsModel|null findOneByFloorPlansSRC($val, array $opt=array()) |
|
| 68 |
+ * @method static RealEstateAssetsModel|null findOneByAvailability($val, array $opt=array()) |
|
| 69 |
+ * @method static RealEstateAssetsModel|null findOneByAvailableFrom($val, array $opt=array()) |
|
| 70 |
+ * @method static RealEstateAssetsModel|null findOneByDescription($val, array $opt=array()) |
|
| 71 |
+ * @method static RealEstateAssetsModel|null findOneByPublished($val, array $opt=array()) |
|
| 72 |
+ * @method static RealEstateAssetsModel|null findOneByStart($val, array $opt=array()) |
|
| 73 |
+ * @method static RealEstateAssetsModel|null findOneByStop($val, array $opt=array()) |
|
| 74 |
+ * |
|
| 75 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByPid($val, array $opt=array()) |
|
| 76 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByTstamp($val, array $opt=array()) |
|
| 77 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByTitle($val, array $opt=array()) |
|
| 78 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByAddress($val, array $opt=array()) |
|
| 79 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByAssetNo($val, array $opt=array()) |
|
| 80 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByLivingSpace($val, array $opt=array()) |
|
| 81 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByNumberOfRooms($val, array $opt=array()) |
|
| 82 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByColdRent($val, array $opt=array()) |
|
| 83 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByAdvanceOperatingCosts($val, array $opt=array()) |
|
| 84 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByCondition($val, array $opt=array()) |
|
| 85 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByConstructionYear($val, array $opt=array()) |
|
| 86 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByCooperativeShares($val, array $opt=array()) |
|
| 87 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByFeatures($val, array $opt=array()) |
|
| 88 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByHeatingType($val, array $opt=array()) |
|
| 89 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByEnergyConsumption($val, array $opt=array()) |
|
| 90 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByGallerySRC($val, array $opt=array()) |
|
| 91 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByFloorPlansSRC($val, array $opt=array()) |
|
| 92 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByAvailability($val, array $opt=array()) |
|
| 93 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByAvailableFrom($val, array $opt=array()) |
|
| 94 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByDescription($val, array $opt=array()) |
|
| 95 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByPublished($val, array $opt=array()) |
|
| 96 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByStart($val, array $opt=array()) |
|
| 97 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findByStop($val, array $opt=array()) |
|
| 98 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findMultipleByIds($val, array $opt=array()) |
|
| 99 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findBy($col, $val, array $opt=array()) |
|
| 100 |
+ * @method static Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null findAll(array $opt=array()) |
|
| 101 |
+ * |
|
| 102 |
+ * @method static integer countById($id, array $opt=array()) |
|
| 103 |
+ * @method static integer countByPid($val, array $opt=array()) |
|
| 104 |
+ * @method static integer countByTstamp($val, array $opt=array()) |
|
| 105 |
+ * @method static integer countByTitle($val, array $opt=array()) |
|
| 106 |
+ * @method static integer countByAddress($val, array $opt=array()) |
|
| 107 |
+ * @method static integer countByAssetNo($val, array $opt=array()) |
|
| 108 |
+ * @method static integer countByLivingSpace($val, array $opt=array()) |
|
| 109 |
+ * @method static integer countByNumberOfRooms($val, array $opt=array()) |
|
| 110 |
+ * @method static integer countByColdRent($val, array $opt=array()) |
|
| 111 |
+ * @method static integer countByAdvanceOperatingCosts($val, array $opt=array()) |
|
| 112 |
+ * @method static integer countByCondition($val, array $opt=array()) |
|
| 113 |
+ * @method static integer countByConstructionYear($val, array $opt=array()) |
|
| 114 |
+ * @method static integer countByCooperativeShares($val, array $opt=array()) |
|
| 115 |
+ * @method static integer countByFeatures($val, array $opt=array()) |
|
| 116 |
+ * @method static integer countByHeatingType($val, array $opt=array()) |
|
| 117 |
+ * @method static integer countByEnergyConsumption($val, array $opt=array()) |
|
| 118 |
+ * @method static integer countByGallerySRC($val, array $opt=array()) |
|
| 119 |
+ * @method static integer countByFloorPlansSRC($val, array $opt=array()) |
|
| 120 |
+ * @method static integer countByAvailability($val, array $opt=array()) |
|
| 121 |
+ * @method static integer countByAvailableFrom($val, array $opt=array()) |
|
| 122 |
+ * @method static integer countByDescription($val, array $opt=array()) |
|
| 123 |
+ * @method static integer countByPublished($val, array $opt=array()) |
|
| 124 |
+ * @method static integer countByStart($val, array $opt=array()) |
|
| 125 |
+ * @method static integer countByStop($val, array $opt=array()) |
|
| 126 |
+ * |
|
| 127 |
+ * @author Benjamin Roth <https://www.vonrotenberg.de> |
|
| 128 |
+ */ |
|
| 129 |
+class RealEstateAssetsModel extends Model |
|
| 130 |
+{
|
|
| 131 |
+ |
|
| 132 |
+ /** |
|
| 133 |
+ * Table name |
|
| 134 |
+ * @var string |
|
| 135 |
+ */ |
|
| 136 |
+ protected static $strTable = 'tl_vr_real_estate_assets'; |
|
| 137 |
+ |
|
| 138 |
+ /** |
|
| 139 |
+ * Find a published assets from one or more categories |
|
| 140 |
+ * |
|
| 141 |
+ * @param int $intId The id of |
|
| 142 |
+ * @param array $arrOptions An optional options array |
|
| 143 |
+ * |
|
| 144 |
+ * @return RealEstateAssetsModel|null A model or null if there is no asset |
|
| 145 |
+ */ |
|
| 146 |
+ public static function findPublishedById(int $intId, array $arrOptions=array()) |
|
| 147 |
+ {
|
|
| 148 |
+ $t = static::$strTable; |
|
| 149 |
+ $arrColumns = array("$t.id=?");
|
|
| 150 |
+ |
|
| 151 |
+ if (!static::isPreviewMode($arrOptions)) |
|
| 152 |
+ {
|
|
| 153 |
+ $time = Date::floorToMinute(); |
|
| 154 |
+ $arrColumns[] = "$t.published='1' AND ($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'$time')"; |
|
| 155 |
+ } |
|
| 156 |
+ |
|
| 157 |
+ return static::findOneBy($arrColumns, $intId, $arrOptions); |
|
| 158 |
+ } |
|
| 159 |
+ |
|
| 160 |
+ /** |
|
| 161 |
+ * Find a published assets from one or more categories |
|
| 162 |
+ * |
|
| 163 |
+ * @param array $arrPids An array of parent IDs |
|
| 164 |
+ * @param integer $intLimit An optional limit |
|
| 165 |
+ * @param integer $intOffset An optional offset |
|
| 166 |
+ * @param array $arrOptions An optional options array |
|
| 167 |
+ * |
|
| 168 |
+ * @return Collection|RealEstateAssetsModel[]|RealEstateAssetsModel|null A collection of models or null if there are no assets |
|
| 169 |
+ */ |
|
| 170 |
+ public static function findPublishedByParent($arrPids, $intLimit=0, $intOffset=0, array $arrOptions=array()) |
|
| 171 |
+ {
|
|
| 172 |
+ if (empty($arrPids) || !\is_array($arrPids)) |
|
| 173 |
+ {
|
|
| 174 |
+ return null; |
|
| 175 |
+ } |
|
| 176 |
+ |
|
| 177 |
+ $t = static::$strTable; |
|
| 178 |
+ $arrColumns = ["$t.pid IN(" . implode(',', array_map('\intval', $arrPids)) . ")"];
|
|
| 179 |
+ |
|
| 180 |
+ if (!static::isPreviewMode($arrOptions)) |
|
| 181 |
+ {
|
|
| 182 |
+ $time = Date::floorToMinute(); |
|
| 183 |
+ $arrColumns[] = "$t.published='1' AND ($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'$time')"; |
|
| 184 |
+ } |
|
| 185 |
+ |
|
| 186 |
+ if (!isset($arrOptions['order'])) |
|
| 187 |
+ {
|
|
| 188 |
+ $arrOptions['order'] = "FIELD($t.pid,".implode(',',$arrPids)."), $t.title ASC, $t.livingSpace ASC";
|
|
| 189 |
+ } |
|
| 190 |
+ |
|
| 191 |
+ $arrOptions['limit'] = $intLimit; |
|
| 192 |
+ $arrOptions['offset'] = $intOffset; |
|
| 193 |
+ |
|
| 194 |
+ return static::findBy($arrColumns, null, $arrOptions); |
|
| 195 |
+ } |
|
| 196 |
+ |
|
| 197 |
+ /** |
|
| 198 |
+ * Find a published assets from one or more categories |
|
| 199 |
+ * |
|
| 200 |
+ * @param array $arrPids An array of parent IDs |
|
| 201 |
+ * @param array $arrOptions An optional options array |
|
| 202 |
+ * |
|
| 203 |
+ * @return integer The number of matching rows |
|
| 204 |
+ */ |
|
| 205 |
+ public static function countPublishedByParent($arrPids, array $arrOptions=array()) |
|
| 206 |
+ {
|
|
| 207 |
+ if (empty($arrPids) || !\is_array($arrPids)) |
|
| 208 |
+ {
|
|
| 209 |
+ return 0; |
|
| 210 |
+ } |
|
| 211 |
+ |
|
| 212 |
+ $t = static::$strTable; |
|
| 213 |
+ $arrColumns = ["$t.pid IN(" . implode(',', array_map('\intval', $arrPids)) . ")"];
|
|
| 214 |
+ |
|
| 215 |
+ if (!static::isPreviewMode($arrOptions)) |
|
| 216 |
+ {
|
|
| 217 |
+ $time = Date::floorToMinute(); |
|
| 218 |
+ $arrColumns[] = "$t.published='1' AND ($t.start='' OR $t.start<='$time') AND ($t.stop='' OR $t.stop>'$time')"; |
|
| 219 |
+ } |
|
| 220 |
+ |
|
| 221 |
+ return static::countBy($arrColumns, null, $arrOptions); |
|
| 222 |
+ } |
|
| 223 |
+} |
|
| 224 |
+ |
|
| 225 |
+class_alias(RealEstateAssetsModel::class, 'RealEstateAssetsModel'); |