Laravel: get table of month's dates via Carbon [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 2 years ago.
Improve this question
I am trying to create a so-called inline calendar for a schedule, where all the current month's dates will be displayed in a 1st table row, like this:
It should display all the dates of the current months and days of week. Also, in the every date cell there will be a select input to choose a work shift, so is it possible to assign some data-attributes to corresponding cell's input (like data-date)?
Is it possible of doing that in the Laravel Blade? By the way, I am planning to display the previous month's dates in another table as well (like for reference).

That's definitely possibly. Since it sounds pretty interactive to me, I would probably combine it with a JS framework like Vue.js. The benefit of using Vue in this case, is that you won't visibly have to submit a form (meaning that the page will refresh) when selecting a work shift: you can easily do this under the hood by sending an Ajax call. It is however not necessary to accomplish what you want.
Using Carbon, you can get the days in the current month by doing:
$period = Carbon\CarbonPeriod::create(Carbon\Carbon::now()->startOfMonth(), Carbon\Carbon::now()->endOfMonth());
foreach($period as $date)
{
$dates[] = $date->format('d-m-Y');
}

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: How to convert a partial date (dd-mm) to time? [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 3 years ago.
Improve this question
I got this .csv file where I have employee number, name and birthday. Birthday comes in dd-mm format (I live in Mexico), how can I convert it to proper date, so I can call date function date('y-m-d', $date) in order to store it in the database?
You can't! At least not reliably. A date must contain the year.
Consider this example:
$dt = DateTime::createFromFormat('d-m', '29-02');
echo $dt->format('Y-m-d'); // 2019-03-01
If an employee's birthday is on the 29th of February and you store it in DB as Date then you are loosing information. To keep the original information intact you need to store it in the format you have received it in, as a VARCHAR field of suitable length.

Autoupdate every day on database [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 6 years ago.
Improve this question
I'm having local MAMP server with phpmyadmin with three tables, users, booking and rooms. In table booking I have something like bookingFrom bookingTo columns that represents booking time. In rooms table I have something like isBooked aswell which is depending on time mostly.
I'd like to make something in my phpmyadmin that every day database will update itself and check if the room is occupied and if the bookingTo date will be before the day that currently is the database will automatically change isBooked from true to false.
My goal isn't the ready script to get, but the way to do it or any useful links as long as it is my training website for school project :)
you can't do such as think with phpmyadmin. You can try mysql scheduler if your version supports it.
Something like that should work...
CREATE EVENT myevent
ON SCHEDULE EVERY 1 DAY
DO
CALL check_book_status();
Please don't forget to create check_book_status function that updates field that you need.
Also, here more information...
http://dev.mysql.com/doc/refman/5.7/en/create-event.html
It might be possible to do this in the database directly, I'm not aware of any method that does this, but I'm sure it's possible (maybe not in mysql, but in some db-engine). However, can't you just do a simple PHP-run of an UPDATE-query at the start of the day (or, whenever), or even just run a cron-script at a specific time (half an hour after checkout, or something like that) and have it check the "end-date" in the database, and if it's before the current date/time, change the "occupied"-status?
You can make it without update status. Suffice calculate status when you show this info:
SELECT
IF(NOW() > bookingFrom AND NOW() < bookingTo, 1, 0) AS isBooked
/* other fields */
FROM booking
...

Display data from Mysql based on date [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 years ago.
Improve this question
I am making a table to display data from a MySQL database, this table will display all the information for the current date but next day it will be blank again and contain no information so you can see the information only for the current day, the data will exist in the database forever however and all data can be displayed upon request!
Now you know my goal i will present the problem, i dont know how to display information for only the current day in the table.
Use data_date=CURDATE() in where condition of your select statement. data_date is your date field separating data for each date...e.g
select * from mydata where data_date=CURDATE()
this will only give the current date data as required
A quick search will bring up similar questions, with answers.
However you can use PHP's date() formatter.
Similar question

Identigy Next Week in PHP [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 8 years ago.
Improve this question
I have a form which user submits and I get the current time and date in the database and facebook ID of the user as well, As per rule the user can fill the form only once in a week, so if he fills the form on Tuesday, he is not eligible to fill the form unless the week is complete, (Only eligible to complete the form again on next Monday)
I am trying to find some php function for weeks but couldn't get so, Anyone can help me what can be done for this logic?
I have date/time in the db for me.
First, you are basically looking for
$date = "2014-10-13";
$week=date("W", strtotime($date));
or even use it this way
$date = "2014-10-13";
$date = new DateTime($date);
$week = $date->format("W");
( http://php.net/manual/en/function.date.php )

Categories