Answer the question
In order to leave comments, you need to log in
How to implement schedule display via TWIG?
Greetings!
I use Slim + Eloquent ORM + Twig.
There is a schedule model:
class Schedule extends Model
{
public function employee()
{
return $this->belongsTo(Employee::class);
}
}
$schedules = Schedule::all();
{"employee_id":260,"start_date":"2020-04-26","start_time":"16:14:39","end_time":"20:14:44"},
{"employee_id":20,"start_date":"2020-04-28","start_time":"16:14:39","end_time":"20:14:44"},
{"employee_id":260,"start_date":"2020-04-29","start_time":"16:14:39","end_time":"20:14:44"},
{"employee_id":20,"start_date":"2020-04-30","start_time":"16:14:39","end_time":"20:14:44"},
{"employee_id":20,"start_date":"2020-05-02","start_time":"16:14:39","end_time":"20:14:44"},
{"employee_id":260,"start_date":"2020-05-02","start_time":"16:14:39","end_time":"20:14:44"}
<table>
<tr>
<th>Сотрудник</th>
<th>26.04</th>
<th>27.04</th>
<th>28.04</th>
<th>29.04</th>
<th>30.04</th>
<th>01.05</th>
<th>02.05</th>
</tr>
<tr>
<td>260</td>
<td>16:14 - 20:14</td>
<td></td>
<td></td>
<td>16:14 - 20:14</td>
<td></td>
<td></td>
<td>16:14 - 20:14</td>
</tr>
<tr>
<td>20</td>
<td></td>
<td></td>
<td>16:14 - 20:14</td>
<td></td>
<td>16:14 - 20:14</td>
<td></td>
<td>16:14 - 20:14</td>
</tr>
</table>
Answer the question
In order to leave comments, you need to log in
You need to parse and organize this data yourself so that you can transfer data from the controller to the template in the form of an array suitable for generating as a table. Move this logic into a separate class, and in the controller, call only the method that converts the raw data to the desired format.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question