diff --git a/app/Http/Controllers/Admin/EducationController.php b/app/Http/Controllers/Admin/EducationController.php index 1b72ae3..9215648 100644 --- a/app/Http/Controllers/Admin/EducationController.php +++ b/app/Http/Controllers/Admin/EducationController.php @@ -13,22 +13,14 @@ use Illuminate\Support\Facades\Storage; class EducationController extends Controller { - /** - * Display a listing of the resource. - * - * @return \Illuminate\Http\Response - */ public function index() { - $education = Education::query()->active()->paginate(15); + $education = Education::query() + ->active() + ->paginate(15); return view('admin.education.index', compact('education')); } - /** - * Show the form for creating a new resource. - * - * @return \Illuminate\Http\Response - */ public function create() { return view('admin.education.add'); diff --git a/app/Http/Controllers/EducationController.php b/app/Http/Controllers/EducationController.php index 10d4c2d..d1c35b2 100644 --- a/app/Http/Controllers/EducationController.php +++ b/app/Http/Controllers/EducationController.php @@ -10,7 +10,7 @@ class EducationController extends Controller { // Образование public function index(Request $request) { - $educations = Education::query(); + $educations = Education::query()->active(); if (($request->has('search')) && (!empty($request->get('search')))) { $search = trim($request->get('search')); $educations = $educations->where('name', 'LIKE', "%$search%"); diff --git a/app/Http/Controllers/EmployerController.php b/app/Http/Controllers/EmployerController.php index ca6b984..bbb3cc1 100644 --- a/app/Http/Controllers/EmployerController.php +++ b/app/Http/Controllers/EmployerController.php @@ -29,11 +29,13 @@ use Illuminate\Database\Eloquent\Builder; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Storage; use App\Models\User as User_Model; use Illuminate\Support\Facades\Validator; use App\Enums\DbExportColumns; +use Throwable; class EmployerController extends Controller { @@ -717,10 +719,9 @@ class EmployerController extends Controller $job_titles = Job_title::query() ->where('is_remove', '=', 0) - ->where('is_bd', '=', 1) + //->where('is_bd', '=', 1) ->orderByDesc('sort') - ->get() - ; + ->get(); if ($sending->sending_is) return view('employers.send_all', compact('job_titles')); @@ -739,16 +740,15 @@ class EmployerController extends Controller 'text' => $data['message_text'], ]); - if (!empty($id)){ - Mail::to(env('EMAIL_ADMIN'))->send(new MassSendingMessages($data)); + try { + if (!empty($id)) { + Mail::to(env('EMAIL_ADMIN'))->send(new MassSendingMessages($data)); + } + } catch (Throwable $e) { + Log::error($e); + return redirect()->route('employer.send_all_messages')->with('error', 'Ошибка почтового сервера, пожалуйста, повторите рассылку позднее'); } - /*$emails = User_Model::query()->where('is_worker', '1')->get(); - - foreach ($emails as $e) { - Mail::to($e->email)->send(new SendAllMessages($data)); - }*/ - return redirect()->route('employer.send_all_messages')->with('success', 'Запрос на рассылку был успешно отправлен.'); } diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 0079688..1c30360 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -2,6 +2,9 @@ namespace App\Http; +use App\Http\Middleware\IsAdmin; +use App\Http\Middleware\IsUserEmployer; +use App\Http\Middleware\IsUserWorker; use Illuminate\Foundation\Http\Kernel as HttpKernel; class Kernel extends HttpKernel @@ -63,5 +66,8 @@ class Kernel extends HttpKernel 'signed' => \App\Http\Middleware\ValidateSignature::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, + 'is_worker' => IsUserWorker::class, + 'is_employer' => IsUserEmployer::class, + 'admin' => IsAdmin::class ]; } diff --git a/app/Http/Middleware/IsAdmin.php b/app/Http/Middleware/IsAdmin.php new file mode 100644 index 0000000..5d26a21 --- /dev/null +++ b/app/Http/Middleware/IsAdmin.php @@ -0,0 +1,19 @@ +is_admin === 1) { + return redirect(RouteServiceProvider::HOME); + } + return $next($request); + } +} diff --git a/app/Http/Middleware/IsUserEmployer.php b/app/Http/Middleware/IsUserEmployer.php new file mode 100644 index 0000000..adade22 --- /dev/null +++ b/app/Http/Middleware/IsUserEmployer.php @@ -0,0 +1,19 @@ +is_worker === 1) { + return redirect(RouteServiceProvider::HOME); + } + return $next($request); + } +} diff --git a/app/Http/Middleware/IsUserWorker.php b/app/Http/Middleware/IsUserWorker.php new file mode 100644 index 0000000..3bc8e9f --- /dev/null +++ b/app/Http/Middleware/IsUserWorker.php @@ -0,0 +1,19 @@ +is_worker !== 1) { + return redirect(RouteServiceProvider::HOME); + } + return $next($request); + } +} diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 843dd92..ce75f8d 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -17,9 +17,9 @@ class RouteServiceProvider extends ServiceProvider * * @var string */ - public const HOME = '/home'; + public const HOME = '/'; - public const LOGIN = '/login'; + public const LOGIN = '/'; /** * Define your route model bindings, pattern filters, and other route configuration. diff --git a/resources/views/chats/chats_list.blade.php b/resources/views/chats/chats_list.blade.php index 9d4cc61..a86eb65 100644 --- a/resources/views/chats/chats_list.blade.php +++ b/resources/views/chats/chats_list.blade.php @@ -1,8 +1,3 @@ - - - - - @if ($chats->count() || $admin_chat) @csrf diff --git a/routes/web.php b/routes/web.php index b096728..8e4f369 100644 --- a/routes/web.php +++ b/routes/web.php @@ -137,7 +137,7 @@ Route::group([ Route::group([ 'as' => 'admin.', // имя маршрута, например auth.index 'prefix' => 'admin', // префикс маршрута, например auth/index - 'middleware' => ['auth'], ['admin'], + 'middleware' => ['auth', 'admin'], ], function() { // выход @@ -502,7 +502,7 @@ Route::get('cookies', function() { Route::group([ 'as' => 'worker.', // имя маршрута, например auth.index 'prefix' => 'worker', // префикс маршрута, например auth/index - 'middleware' => ['auth'], ['is_worker'], + 'middleware' => ['auth', 'is_worker'], ], function() { // Формы редактирования Route::get('cabinet/basic_information', [WorkerController::class, 'basic_information'])->name('basic_information'); @@ -573,7 +573,7 @@ Route::group([ Route::group([ 'as' => 'employer.', // имя маршрута, например auth.index 'prefix' => 'employer', // префикс маршрута, например auth/index - 'middleware' => ['auth'], !['is_worker'], + 'middleware' => ['auth', 'is_employer'], ], function() { // 0 страница - Личные данные работодателя Route::get('cabinet/employer_info', [EmployerController::class, 'employer_info'])->name('employer_info');