Пример #1
0
 static function getBatchID($courseId, $classId, $startYear, $startMonth, $seasonId)
 {
     if (Batches::count()) {
         $batchCount = Batches::where("class_id", "=", $classId)->where('season_id', '=', $seasonId)->count() + 1;
     } else {
         $batchCount = 1;
     }
     if ($batchCount < 10) {
         $batchCount = str_pad($batchCount, 2, '0', STR_PAD_LEFT);
     }
     $courseSlug = Courses::select("slug")->where("id", "=", $courseId)->get();
     $classSlug = Classes::select("slug")->where("id", "=", $classId)->get();
     $yearSlug = date("Y", strtotime($startYear));
     $monthSlug = date("M", strtotime($startYear));
     $batchSlug = $courseSlug['0']->slug . '-' . $classSlug['0']->slug . '-' . strtoupper($monthSlug) . '-' . $yearSlug . '-' . $batchCount;
     //print_r($classSlug['0']->slug);
     return $batchSlug;
 }