<?php

namespace App\Models;

use DateTime;
use DateInterval;
use DatePeriod;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class ClassRoomActivity extends Model
{
  use HasFactory;

  protected $fillable = ['date_epoch', 'classroomId', 'scheduleId'];

  public function createClassRoomActivity(array $data)
  {
    return DB::transaction(function () use ($data) {
      // NOTE: obsoleted

      // $classRoomId = $data['classRoomId'];
      // $scheduleId = $data['scheduleId'];

      // $startTime = $data['startTime'];
      // $endTime = $data['endTime'];

      // $begin = new DateTime($startTime);
      // $end = new DateTime($endTime);

      // $interval = DateInterval::createFromDateString('1 day');
      // $period = new DatePeriod($begin, $interval, $end);

      // $arr = [];
      // foreach ($period as $dt) {
      //     array_push($arr, $dt->format("Y-m-d"));
      // }
      // array_push($arr, $end->format("Y-m-d"));

      // foreach ($arr as $day) {
      //     $class_room_activity = self::create([
      //         // strtotime('01-01-2023')
      //         'date_epoch' => '88888',
      //         'classroomId' => $classRoomId,
      //         'scheduleId' => $scheduleId,
      //     ]);
      // }

      // return $class_room_activity;
      return true;
    });
  }
}
