private function generateEmail() { do { $digits = rand(100000, 999999); $format = '*****@*****.**'; $email = sprintf($format, $digits); $count = Student::where('email', $email)->count(); } while ($count > 0); return $email; }
public function finishedPercent() { try { $students = Student::where('traits_type', '=', 'TT\\Models\\StudentTrait')->select('id'); $studentsFinished = \DB::table('users_activities')->select('id')->distinct(); $students = count($students); $studentsFinished = count($studentFinished); if ($students <= 0 || $studentFinished <= 0) { return 0; } $total = bcdiv($studentsFinished, $students, 3) * 100; return $total; } catch (\Exception $ex) { \Log::error($ex); return 0; } }