public function get(Jam_Validated $model, $value, $is_changed) { if (!$value and !$is_changed and !$model->loaded()) { return Request::$client_ip; } return $value; }
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()); } }
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; }