diff --git a/app/Console/Commands/ResetData.php b/app/Console/Commands/ResetData.php new file mode 100644 index 0000000..22fbef0 --- /dev/null +++ b/app/Console/Commands/ResetData.php @@ -0,0 +1,131 @@ +whereHas('workers') + ->where('is_bd', 0) + ->where('created_at', '<', '2024-11-30 00:00:00') + ->whereNotIn('email', [ + 'vkontakte@rekamore.su', + '2anketa@rekamore.su' + ]) + ->get(); + + foreach ($users as $user) { + Answer::query()->where(['user_id' => $user->id])->delete(); + + Chat::query()->where(['user_id' => $user->id])->delete(); + Chat::query()->where(['to_user_id' => $user->id])->delete(); + Message::query()->where(['user_id' => $user->id])->delete(); + Message::query()->where(['to_user_id' => $user->id])->delete(); + MessagesRequests::query()->where(['user_id' => $user->id])->delete(); + + Group_user::query()->where(['user_id' => $user->id])->get()->map(function ($groupUser) { + Group_works::query()->where(['group_user_id' => $groupUser->id])->delete(); + $groupUser->delete(); + }); + + Like_vacancy::query()->where(['user_id' => (string)$user->id])->delete(); + Like_worker::query()->where(['user_id' => (string)$user->id])->delete(); + Media::query()->where(['user_id' => $user->id])->delete(); + Static_worker::query()->where(['user_id' => $user->id])->delete(); + +// $user->employers()->get()->map(function ($employer) { +// Answer::query()->where(['employer_id' => $employer->id])->delete(); +// +// Ad_employer::query()->where(['employer_id' => $employer->id])->get()->map(function ($adEmployer) { +// Ad_jobs::query()->where(['ad_employer_id' => $adEmployer->id])->delete(); +// ad_response::query()->where(['ad_employer_id' => $adEmployer->id])->delete(); +// Static_ad::query()->where(['ad_employer_id' => $adEmployer->id])->delete(); +// Like_vacancy::query()->where(['code_record' => $adEmployer->id])->delete(); +// +// $adEmployer->delete(); +// }); +// +// Contacts::query()->where(['employer_id' => $employer->id])->delete(); +// employers_main::query()->where(['employer_id' => $employer->id])->delete(); +// EmployerAutoliftOption::query()->where(['employer_id' => $employer->id])->delete(); +// +// Flot::query()->where(['employer_id' => $employer->id])->delete(); +// +// $employer->delete(); +// }); + + $user->workers()->get()->map(function ($worker) { + Dop_info::query()->where(['worker_id' => $worker->id])->delete(); + PrevCompany::query()->where(['worker_id' => $worker->id])->delete(); + ResponseWork::query()->where(['worker_id' => $worker->id])->delete(); + Like_worker::query()->where(['code_record' => $worker->id])->delete(); + Title_worker::query()->where(['worker_id' => $worker->id])->delete(); + WorkerAutoliftOption::query()->where(['worker_id' => $worker->id])->delete(); + $worker->delete(); + }); + + $user->delete(); + + } + + User::query()->where('password', 1234567890)->get()->map(function ($userBd) { + $password = $userBd->password; + + $userBd->update([ + 'password' => Hash::make($password), + 'pubpassword' => base64_encode($password), + ]); + }); + + return Command::SUCCESS; + } +} diff --git a/app/Http/Controllers/Admin/UsersController.php b/app/Http/Controllers/Admin/UsersController.php index 0222b99..f9b2042 100644 --- a/app/Http/Controllers/Admin/UsersController.php +++ b/app/Http/Controllers/Admin/UsersController.php @@ -10,6 +10,7 @@ use App\Models\User; use App\Models\Worker; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Storage; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Style\Alignment; @@ -104,6 +105,10 @@ class UsersController extends Controller $params['name'] = $request->surname." ".$request->name_man." ".$request->surname2; } + $password = $params['password']; + $params['password'] = Hash::make($password); + $params['pubpassword'] = base64_encode($password); + $user = User::create($params); $worker = new Worker(); $worker->positions_work = isset($params['positions_work']) ? json_encode($params['positions_work']) : []; diff --git a/app/Http/Controllers/Admin/WorkersController.php b/app/Http/Controllers/Admin/WorkersController.php index b7e3527..7e1f324 100644 --- a/app/Http/Controllers/Admin/WorkersController.php +++ b/app/Http/Controllers/Admin/WorkersController.php @@ -34,25 +34,25 @@ class WorkersController extends Controller $find_status_work = $request->status_work; if ($request->status_work > 0) { - $users = $users->with('workers')-> + $users = $users-> whereHas('workers', function (Builder $query) use ($find_status_work) { $query->where('position_work', $find_status_work); } ); } else { - $users = $users->with('workers'); + $users = $users->whereHas('workers'); } } else { - $users = $users->with('workers'); + $users = $users->whereHas('workers'); } $find_key = ""; if (isset($request->find)) { $find_key = $request->find; $users = $users->where(function($query) use($find_key) { - $query->Where('name_man', 'LIKE', "%$find_key%") + $query->where('name_man', 'LIKE', "%$find_key%") ->orWhere('email', 'LIKE', "%$find_key%") ->orWhere('telephone', 'LIKE', "%$find_key%") ->orWhere('surname', 'LIKE', "%$find_key%") @@ -60,7 +60,9 @@ class WorkersController extends Controller }); } - $users = $users->orderByDesc('id')->Realuser()->paginate(15); + $all_worker = $users->count(); + + $users = $users->orderByDesc('id')->paginate(15); $status_wor = WorkerStatuses::getWorkerStatuses(); diff --git a/resources/views/admin/worker/index.blade.php b/resources/views/admin/worker/index.blade.php index ccdfd85..a672584 100644 --- a/resources/views/admin/worker/index.blade.php +++ b/resources/views/admin/worker/index.blade.php @@ -72,7 +72,7 @@ > № Лого - ФИО/Email/Телефон + ФИО/Email/Телефон/Пароль Статус % анкеты Должность @@ -116,16 +116,23 @@

- @if (isset($user->id)) - {{ $user->surname }} {{ !empty($user->name_man) ? $user->name_man : $user->name }} {{ $user->surname2 }} - @else - {{ $user->surname }} {{ !empty($user->name_man) ? $user->name_man : $user->name }} {{ $user->surname2 }} - @endif + @if (isset($user->id)) + {{ $user->surname }} {{ !empty($user->name_man) ? $user->name_man : $user->name }} {{ $user->surname2 }} + @else + {{ $user->surname }} {{ !empty($user->name_man) ? $user->name_man : $user->name }} {{ $user->surname2 }} + @endif +

+{{--

{{ empty($user->workers->email) ? $user->email : $user->workers->email }}

--}} +

{{ $user->email }}

+

+ {{ empty($user->workers->telephone) ? $user->telephone : $user->workers->telephone }} +

+

+ @if (!empty($user->pubpassword)) + {{ base64_decode($user->pubpassword) }} + @endif

-

{{ empty($user->workers->email) ? $user->email : $user->workers->email }}

-

- {{ empty($user->workers->telephone) ? $user->telephone : $user->workers->telephone }} -

diff --git a/resources/views/admin/worker/index_ajax.blade.php b/resources/views/admin/worker/index_ajax.blade.php index 3bfbee4..4f510dd 100644 --- a/resources/views/admin/worker/index_ajax.blade.php +++ b/resources/views/admin/worker/index_ajax.blade.php @@ -7,7 +7,7 @@ > № Лого - ФИО/Email/Телефон + ФИО/Email/Телефон/Пароль Статус % анкеты Должность @@ -58,6 +58,11 @@

{{ empty($user->workers->telephone) ? $user->telephone : $user->workers->telephone }}

+

+ @if (!empty($user->pubpassword)) + {{ base64_decode($user->pubpassword) }} + @endif +