示例#1
0
 public function get(Jam_Validated $model, $value, $is_changed)
 {
     if (!$value and !$is_changed and !$model->loaded()) {
         return Request::$client_ip;
     }
     return $value;
 }
示例#2
0
文件: Creator.php 项目: Konro1/pms
 public function model_before_check(Jam_Validated $model, $value, $changed)
 {
     if (!$model->loaded() and !isset($changed[$this->name]) and Jam_Association_Creator::current()) {
         $model->{$this->name} = Jam::find($this->foreign_model, Jam_Association_Creator::current());
     }
 }
示例#3
0
文件: Hasone.php 项目: sdipchikov/jam
 public function set(Jam_Validated $model, $value, $is_changed)
 {
     if ($value instanceof Jam_Model) {
         if ($this->is_polymorphic()) {
             $value->{$this->polymorphic_key} = $model->meta()->model();
         }
         if ($model->loaded()) {
             $value->{$this->foreign_key} = $model->id();
         }
         if ($this->as) {
             $value->retrieved($this->as, $model);
         }
         if ($this->inverse_of) {
             $value->retrieved($this->inverse_of, $model);
         }
     }
     return $value;
 }