wikipoints/ground/models/Point.php

33 lines
613 B
PHP

<?php
class Point extends Model
{
function __construct($fromArray = array())
{
$this->_tableName_ = 'points';
parent::__construct($fromArray);
$this->setRelation('category', 'categoryId', 'Category', 'id', self::TO_ONE);
$this->setRelation('authorUser', 'author', 'User', 'id', self::TO_ONE);
$this->setRelation('photos', 'id', 'Photo', 'pointId', self::TO_MANY);
}
static function model()
{
return new self();
}
public function getImg()
{
$img = $this->img;
if ($img == '')
{
$img = array_shift($this->photos);
$img = '/photos/middle/' . $img->name;
}
return $img;
}
}