0

We are developing a simple attendance system based on Laravel Framework. We are new to Laravel framework. We use the basic auth system of Laravel. The user can check in / check out using the system. While doing,the user is supposed to take a photo of their own and we also get the location details from browser.

For attendance, we have the following schema: id (primary Key) (int) userid (int) (foreign key to id of the user table) status (boolean) ( 0 - out / 1 - in) attendancedatetime (datetime) gpslat (float) gpslon (float) photourl (varchar)

Now we wish to avoid check-in/check-out by an user within few minutes (say for example within 10 minutes).

Also, we wish to avoid multiple check-in or multiple check-out by the same user at a time.

Is it possible to do this in Laravel Controller?

Will this provide any solution to our problem?

Rot-man
  • 18,045
  • 12
  • 118
  • 124
Guest
  • 3
  • 4
  • Can you give some examples of multiple check-in, check-out and it's use cases? – nice_dev Mar 09 '19 at 07:38
  • for example the user may have checked in at 9.00 a.m. the system should consider the next one as check out which should be considered only after some **x** minutes say 30 minutes. Also, within a day the same user 'check out ' and 'check in' of lunch should also need to be noted (sorry for bad english) – Guest Mar 09 '19 at 16:02

1 Answers1

0

Firstly Find out last checked details by

select max(time(attendancedatetime)) as last_checked_time
From<TableName>
WHERE userid=<USERID> and DATE(attendancedatetime)=<Current Date>

after that in Laravel, compare this returned last_checked_time with current time. If it is less then 30 minutes return false else run your insert statement!