Hey guys,
any idea how to do this, perhaps in the \Phalcon\Mvc\Model::initialize(), without having to override find()/findFirst() each time? Setting some sort of default condition.
Basically, I want to keep the record in the database but hidden from the app for historical purposes only with the possibility to reintegrate back in the system easily. And I would like to avoid having to move it to some archive.
<?php
namespace Models;
use Phalcon\Mvc\Model;
class Metrics extends Model
{
public static function find($parameters = null)
{
$condition = 'retired is null';
if (is_array($parameters)) {
if ( isset($parameters[0])) {
$parameters[0] .= ' and '.$condition;
}
else {
$parameters[0] = $condition;
}
}
elseif ($parameters) {
$parameters .= ' and '.$condition;
}
else {
$parameters = $condition;
}
return parent::find($parameters);
}
}
Thanks, Marek