Laravel - Managing Time for a riddle site [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am using laravel to build a riddle web application where user can post the riddle and set a end time (eg: 10hrs/2days from the date of post). Other members can answer the riddle within the given time. best answer within time wins. I want that the riddle will not show up in page if the time has ended.
I need guidance on how can I approach only the section where riddle is not available after the time limit. Will checking current time with posted time can help? or there is other easier way.
I am new to laravel.
Thanks in advance.

I would store are riddles in the database. You insert them and you give them a startdate, wich can be your current time... and an end date. This value is something you can set in the back-end.
When a user wants to visit a page, you do a time time check for example: (Dummy data)
The user navigates to:
www.riddles.com/112
You check if the id 112 exists. ( FindOrFail ).
Yes, it exists?
Do a check in your database for the endtime. If this end-time is not yet reached you show the page. Else you redirect to some other page.
Your question wasn't 100% clear to me but I guess that is something you would like to start doing? If not, please give a more detailed explanation.

Related

Display status based on due dates [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 months ago.
Improve this question
OK, I understand the title might be little confusing. Sorry about that.
This question doesn't have anything with coding, I just want your advice on how to approach to solve this task.
I'm using Laravel 8.
I got these reports that need to be uploaded on various dates (usually at the end of every quarter) throughout every year. I want to display the reports the user hasn't uploaded, with their due date and the status.
Something like this:
All the reports have a separate Model, Controller and db tables.
So, my question is how do I check whether a certain type of report has been uploaded by the user within the required dates (or before the due date)? Any ideas?
I hope you understood my question. Thank you.
First, check if the file exists. If not, then output the necessary statement. Something like: 'Report has not been submitted"
if the file is present, check the file creation date on the server and compare it to the required dates. If it is before the due date, output "Report submitted on time". Otherwise, output "Report submitted late"
The file information can be found using stat([filename]).

PHP : Keeping track of first login and last logout in mysql [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am doing simple sales application where salesman logs in and keeps entering data for all the meetings/ calls he makes . In my sales person table I've to keep track of first and last login of the day , i am really unable to develop any logic for that i mean how can i detect if this was first login and keep it stored in db and then last logout of the day , can some one help me with the logic or refer me some links to go through some related stuff
Every login do the following:
If there is no "first-login value" set for that day in the database, (create it) and set it to that time. also set the "last-login value" to the same time.
If there is already a "first-login-value" for that day, do not touch it. just set the "last-login value" to the current time.
It can be summarized in the following pseudo-code:
// salesman logs in
// check in database first and last login time
if (first-login-time is not set) {
Now set the first-login-time in the database to the current time
}
// you always need to do this
Now set the last-login-time in the database
At the end of the day, you'll either have no values (no login). Both values to the same time (one login). Or two different values, which will be the first and last login time.

Number of users on current page [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I've my application built on Laravel 4.1. In my application I want to get number of authentic users currently watching a particular page, like if the application has page1, page2. I want to know the number of users currently on page 1 vs. on page 2.
How can I implement this feature in laravel?
This is a very unique problem and there is not a straight solution to this anyway.
$users = count(glob(session_save_path() . '/*'));
Note that this just counts session files. It will undoubtedly contain stale/dead sessions that haven't been garbage collected yet.
A better way according to me would be if you create time stamps for each of your page and have every page issue and ajax call to the server every few seconds to update these timestamps.
So if a user is on a particular page, the page will keep sending requests to the server every few seconds and the time stamps will be updated.
You can then calculate the number of users on a particular page by querying the time stamps for the last minute or something.

How to deactivate or remove an item from my database after a specific time? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a project that requires me to develop a website say like ebay or craigslist where users will be uploading ads and items for sale or maybe advertisement purposes. I want the users to have an option of duration that how long they would want their items to remain on the website. Let say the options are 7 days, 15 days and 30 days, if a user selects 15 days for his/her item to remain on the website, I want a simple and reliable solution that automatically deactivates or removes this specific item from the database after 15 days at exactly the same time of upload. (Must be accurate up to minutes and even seconds). Since I love php so much, I would also love if the answer is simply possible in php. Anyway, if there is another solution more reliable let me know it. I have been considering setting a $_SESSION[] and then destroying it after the time limit but I have this feeling that it may not be the best approach available. Whatever,,,,, Please help me out, Please explain. Thank you in advance.
This may help you.
DELETE FROM table WHERE delete_date >= (CURDATE() - INTERVAL 7 DAY);

Suitable architecture for storing "Seen" messages [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm sure all of you have seen at some point at some website some message - i.e. you logged in and it stated something like "There will be a planned maintenance downtime at Tuesday 5PM PST". And then you have the tick mark for the message. When you click on it, you don't get the message shown any more.
Now, my question is how to handle this in the database. I.e. if you have 1M registered users and you decide to store this "seen" record for every user you'll end up with a 1M table which has to be read from every time someone logs in. On the other hand, if you have 10 messages like that - of course your table grows much faster. And finally, there could be messages like "Johnny,Harry,Diane and 5 of your other friends have updated their profile."
You could have like 10-50 messages like that daily. What I'm trying to think of is the best approach to this. I've implemented a lot of solutions in the past but I'm rethinking and am wondering of how others in the community are handling problems like that!
Edit:
#hakre
Thank you for your comment. Actually, I did describe one way I handled it in the question itself. Don't get me wrong but if I propose solutions, answers tend to discuss those proposed solutions which isn't something I'd like.
Do you have any NoSQL at hands?
I use redis, and I would create an set with all the users ids as members of the set (add the ids if the user should be marked as seen)... To check if the user has seen the message a simple SISMEMBER will suffice and it's O(1)...
Plus, you won't need any db query or alter table for the seen field.
http://redis.io/commands/sismember

Categories