Support the ongoing development of Laravel.io →
Database Eloquent Blade
Last updated 2 years ago.
0

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?

Last updated 2 years ago.
0

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?

Last updated 2 years ago.
0

You could use a model observer, but in this case I think using a mutator on the model would be the easier choice.

http://laravel.com/docs/eloquent#model-observers

http://laravel.com/docs/eloquent#accessors-and-mutators

Last updated 2 years ago.
0

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';

}
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

LOGINGRUPA logingrupa Joined 24 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.