calculate Attendance
Hello, I would like to implement the number of hours worked into the formula via Carbon. Can I ask for advice?
24 Replies
Yes you can ask advice, dont know if anyone can help you but please ask.
Also share some code so whe know what you are talking about.
here are the attached files
I think you can make mutator for this?
i have something simular, if you want to set you total you could do something like this in your model
For me i can start and stop time so it is different than yours, i store the time in minutes and have a function to format it as hours.
I don't know what you mean.
^
If you just use 2 dateTime you can use diffInHours 😛
Will this also show the remaing minutes?
You could by using
$end->diffInMinutes(now())
Something like that (not tested)For me i only have the minutes total, i can start and stop and than later start and stop again and it will add minutes. did not yet get this working with carbon or something like that
Carbon - A simple PHP API extension for DateTime.
Carbon - A simple PHP API extension for DateTime.
Sorry, i know now why i use minutes.
i want total hours, and if the hours are more dan 24 it showd me 2 insted of 26.
$start->diffInHours($end)
true, only than for every time entry i need to group them.
Now i have 1 time entry, my customers dont want to know what time i started and what time i ended only the total time for me to work on a project line
I don't understand:squint: , you can probably create an observer that calculates the time when you create the record, or you can make an attribute.
I'm rebuilding my project as saas application and will try this when i'm at this point in coding.
I added the sample code and it threw me an error Calling member function diffInMinutes() on string
Yes that only works on a Carbon object
You need to cast in your model
something like this
it seems to work but the data is not uploaded to the database
And if you update?
this will set total on creating and updating
Would be nice to have observer no?
not even with the update
How does you model class look now?
it's working now thank you very much