phplaravelcheckoutcheckin

Laravel - php Identifying multiple check in / check out in attendance


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?


Solution

  • 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!