Answer the question
In order to leave comments, you need to log in
How to do free time check for Yii2 entry?
Hello, I am developing a system for recording filming, I would like to know how to check a person’s free time for recording, day and time, (an analogy for an appointment with a doctor, a doctor cannot see several people at the same time)
There is a table - an event
where id_operator, id_journalist, id_driver , id_car is taken from the table
, you need to check everyone for free time,
and I also wanted to know how to make a selection when recording - showing free dates / times for recording as in public services when making an appointment with a doctor
or
Datetimepickere displayed free time for recording
Googling aside, what to read
found a similar example, but here the time and date are different fields,
is it possible to split when checking DATETIME for further use in fullcalendar?
class Record extends ActiveRecord
{
// you code
public function rules()
{
return [
// you code
[['time', 'data', 'doctor_fio'], 'required'],
['doctor_fio', 'validateRecord'],
];
}
public function validateRecord($attribute)
{
// Условие в выражение where установите то, которое вам нужно.
// Ниже приведен как пример.
$exist = self::find()
->where([
'time' => $this->time,
'date' => $this->date,
'doctor_fio' => $this->doctor_fio,
])->exists();
if ($exist) {
$this->addError($attribute, "Запись на это время не возможна");
}
}
// you code
}
Answer the question
In order to leave comments, you need to log in
At first you receive the information on what there are records for this day.
Then you form possible intervals for this day in increments of 15 minutes, for example, you check whether there is already a record for this interval, if not, you display it, otherwise you hide it. All.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question