Поиск разблокированных - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of Поиск разблокированных.php
- $hisories = PersonSyncHistory::query()
- ->with('event')
- ->whereHas('event', function ($query) {
- $query->whereIn('code', LeadSyncStatus::BLOCK_EVENTS);
- })
- ->orderBy('created_at', 'ASC')
- ->get()
- ->groupBy(['user_id']);
- $count = 0;
- $batch = [];
- foreach ($hisories as $users) {
- $reserve = true;
- foreach ($users as $user) {
- if ($user->event->code == 18 || $user->event->code == 19 || $user->event->code == 20 || $user->event->code == 21 || $user->event->code == 22 || $user->event->code == 23) {
- $reserve = false;
- }
- if ($reserve == false && ($user->event->code == 6 || $user->event->code == 7 || $user->event->code == 8 || $user->event->code == 9 || $user->event->code == 10 || $user->event->code == 11)) {
- $count++;
- dd($user);
- $batch[] = $users;
- file_put_contents('lead-reserv.txt', "{$user->user->full_name}\n", FILE_APPEND);
- break;
- }
- }
- }
- dd($count);