So, just to make sure that I understand, you want to ask for the datetimefrom only then calculate the other three based on that value? I don't see why you couldn't do that right in the controller. Just do all those calculations before you assign the values to the Event object and insert.
Does this help or am I missing something?
noelmcavoy said:
So, just to make sure that I understand, you want to ask for the datetimefrom only then calculate the other three based on that value? I don't see why you couldn't do that right in the controller. Just do all those calculations before you assign the values to the Event object and insert.
Does this help or am I missing something?
Thanks, Yes, that's right! But how to do it? How to use that Event object?
You could use a model observer, but in this case I think using a mutator on the model would be the easier choice.
In your Procedure model you can do something like:
public function setDatetimefromAttribute($value) {
/** Set the initital value **/
$this->attributes['datetimefrom'] = $value;
/** Do all your calculations and set those fields. **/
$this->attributes['timefrom'] = 'do your calculation';
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community