| Total Complexity | 3 |
| Total Lines | 17 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class SignupStat extends Model |
||
| 9 | { |
||
| 10 | use HasFactory; |
||
| 11 | |||
| 12 | protected $guarded = []; |
||
| 13 | |||
| 14 | public static function insertUsersByMonth(): void |
||
| 15 | { |
||
| 16 | $users = User::query()->whereNotNull('created_at')->where('created_at', '<>', '0000-00-00 00:00:00')->selectRaw("DATE_FORMAT(created_at, '%M %Y') as mth, COUNT(id) as num")->groupBy(['mth'])->orderByDesc('created_at')->get(); |
||
|
|
|||
| 17 | foreach ($users as $user) { |
||
| 18 | self::updateOrCreate(['month' => $user->mth], ['signups' => $user->num]); |
||
| 19 | } |
||
| 20 | } |
||
| 21 | |||
| 22 | public static function getUsersByMonth(): array |
||
| 25 | } |
||
| 26 | } |
||
| 27 |