37 lines
620 B
PHP
37 lines
620 B
PHP
<?php
|
|
namespace Incoviba\old\Common;
|
|
|
|
use Incoviba\Common\Alias\OldModel as Model;
|
|
|
|
/**
|
|
*
|
|
* @author Aldarien
|
|
*
|
|
* @property int id
|
|
* @property string calle
|
|
* @property int numero
|
|
* @property string extra
|
|
* @property Comuna comuna
|
|
*
|
|
*/
|
|
class Direccion extends Model
|
|
{
|
|
public function comuna()
|
|
{
|
|
return $this->belongs_to(Comuna::class, 'comuna')->findOne();
|
|
}
|
|
|
|
public function completa($comuna = false)
|
|
{
|
|
$str = $this->calle . ' ' . $this->numero;
|
|
if ($this->extra != '') {
|
|
$str .= ', ' . $this->extra;
|
|
}
|
|
if ($comuna) {
|
|
$str .= ', ' . $this->comuna()->descripcion;
|
|
}
|
|
return $str;
|
|
}
|
|
}
|
|
?>
|