Commit 31e0a8793ea2733bb379462f86b60c02d5fbcb10
1 parent
8633df6d3f
Exists in
master
task-132687 доделки без номеров
Showing 10 changed files with 83 additions and 33 deletions Side-by-side Diff
- app/Http/Controllers/Admin/EducationController.php
- app/Http/Controllers/EducationController.php
- app/Http/Controllers/EmployerController.php
- app/Http/Kernel.php
- app/Http/Middleware/IsAdmin.php
- app/Http/Middleware/IsUserEmployer.php
- app/Http/Middleware/IsUserWorker.php
- app/Providers/RouteServiceProvider.php
- resources/views/chats/chats_list.blade.php
- routes/web.php
app/Http/Controllers/Admin/EducationController.php
... | ... | @@ -13,22 +13,14 @@ use Illuminate\Support\Facades\Storage; |
13 | 13 | |
14 | 14 | class EducationController extends Controller |
15 | 15 | { |
16 | - /** | |
17 | - * Display a listing of the resource. | |
18 | - * | |
19 | - * @return \Illuminate\Http\Response | |
20 | - */ | |
21 | 16 | public function index() |
22 | 17 | { |
23 | - $education = Education::query()->active()->paginate(15); | |
18 | + $education = Education::query() | |
19 | + ->active() | |
20 | + ->paginate(15); | |
24 | 21 | return view('admin.education.index', compact('education')); |
25 | 22 | } |
26 | 23 | |
27 | - /** | |
28 | - * Show the form for creating a new resource. | |
29 | - * | |
30 | - * @return \Illuminate\Http\Response | |
31 | - */ | |
32 | 24 | public function create() |
33 | 25 | { |
34 | 26 | return view('admin.education.add'); |
app/Http/Controllers/EducationController.php
... | ... | @@ -10,7 +10,7 @@ class EducationController extends Controller |
10 | 10 | { |
11 | 11 | // Образование |
12 | 12 | public function index(Request $request) { |
13 | - $educations = Education::query(); | |
13 | + $educations = Education::query()->active(); | |
14 | 14 | if (($request->has('search')) && (!empty($request->get('search')))) { |
15 | 15 | $search = trim($request->get('search')); |
16 | 16 | $educations = $educations->where('name', 'LIKE', "%$search%"); |
app/Http/Controllers/EmployerController.php
... | ... | @@ -29,11 +29,13 @@ use Illuminate\Database\Eloquent\Builder; |
29 | 29 | use Illuminate\Http\Request; |
30 | 30 | use Illuminate\Support\Facades\Auth; |
31 | 31 | use Illuminate\Support\Facades\Hash; |
32 | +use Illuminate\Support\Facades\Log; | |
32 | 33 | use Illuminate\Support\Facades\Mail; |
33 | 34 | use Illuminate\Support\Facades\Storage; |
34 | 35 | use App\Models\User as User_Model; |
35 | 36 | use Illuminate\Support\Facades\Validator; |
36 | 37 | use App\Enums\DbExportColumns; |
38 | +use Throwable; | |
37 | 39 | |
38 | 40 | class EmployerController extends Controller |
39 | 41 | { |
... | ... | @@ -717,10 +719,9 @@ class EmployerController extends Controller |
717 | 719 | |
718 | 720 | $job_titles = Job_title::query() |
719 | 721 | ->where('is_remove', '=', 0) |
720 | - ->where('is_bd', '=', 1) | |
722 | + //->where('is_bd', '=', 1) | |
721 | 723 | ->orderByDesc('sort') |
722 | - ->get() | |
723 | - ; | |
724 | + ->get(); | |
724 | 725 | |
725 | 726 | if ($sending->sending_is) |
726 | 727 | return view('employers.send_all', compact('job_titles')); |
... | ... | @@ -739,16 +740,15 @@ class EmployerController extends Controller |
739 | 740 | 'text' => $data['message_text'], |
740 | 741 | ]); |
741 | 742 | |
742 | - if (!empty($id)){ | |
743 | - Mail::to(env('EMAIL_ADMIN'))->send(new MassSendingMessages($data)); | |
743 | + try { | |
744 | + if (!empty($id)) { | |
745 | + Mail::to(env('EMAIL_ADMIN'))->send(new MassSendingMessages($data)); | |
746 | + } | |
747 | + } catch (Throwable $e) { | |
748 | + Log::error($e); | |
749 | + return redirect()->route('employer.send_all_messages')->with('error', 'Ошибка почтового сервера, пожалуйста, повторите рассылку позднее'); | |
744 | 750 | } |
745 | 751 | |
746 | - /*$emails = User_Model::query()->where('is_worker', '1')->get(); | |
747 | - | |
748 | - foreach ($emails as $e) { | |
749 | - Mail::to($e->email)->send(new SendAllMessages($data)); | |
750 | - }*/ | |
751 | - | |
752 | 752 | return redirect()->route('employer.send_all_messages')->with('success', 'Запрос на рассылку был успешно отправлен.'); |
753 | 753 | } |
754 | 754 |
app/Http/Kernel.php
... | ... | @@ -2,6 +2,9 @@ |
2 | 2 | |
3 | 3 | namespace App\Http; |
4 | 4 | |
5 | +use App\Http\Middleware\IsAdmin; | |
6 | +use App\Http\Middleware\IsUserEmployer; | |
7 | +use App\Http\Middleware\IsUserWorker; | |
5 | 8 | use Illuminate\Foundation\Http\Kernel as HttpKernel; |
6 | 9 | |
7 | 10 | class Kernel extends HttpKernel |
... | ... | @@ -63,5 +66,8 @@ class Kernel extends HttpKernel |
63 | 66 | 'signed' => \App\Http\Middleware\ValidateSignature::class, |
64 | 67 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, |
65 | 68 | 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, |
69 | + 'is_worker' => IsUserWorker::class, | |
70 | + 'is_employer' => IsUserEmployer::class, | |
71 | + 'admin' => IsAdmin::class | |
66 | 72 | ]; |
67 | 73 | } |
app/Http/Middleware/IsAdmin.php
... | ... | @@ -0,0 +1,19 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace App\Http\Middleware; | |
4 | + | |
5 | +use App\Providers\RouteServiceProvider; | |
6 | +use Closure; | |
7 | +use Illuminate\Http\Request; | |
8 | +use Illuminate\Support\Facades\Auth; | |
9 | + | |
10 | +class IsAdmin | |
11 | +{ | |
12 | + public function handle(Request $request, Closure $next) | |
13 | + { | |
14 | + if (Auth::user()->is_admin === 1) { | |
15 | + return redirect(RouteServiceProvider::HOME); | |
16 | + } | |
17 | + return $next($request); | |
18 | + } | |
19 | +} |
app/Http/Middleware/IsUserEmployer.php
... | ... | @@ -0,0 +1,19 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace App\Http\Middleware; | |
4 | + | |
5 | +use App\Providers\RouteServiceProvider; | |
6 | +use Closure; | |
7 | +use Illuminate\Http\Request; | |
8 | +use Illuminate\Support\Facades\Auth; | |
9 | + | |
10 | +class IsUserEmployer | |
11 | +{ | |
12 | + public function handle(Request $request, Closure $next) | |
13 | + { | |
14 | + if (Auth::user()->is_worker === 1) { | |
15 | + return redirect(RouteServiceProvider::HOME); | |
16 | + } | |
17 | + return $next($request); | |
18 | + } | |
19 | +} |
app/Http/Middleware/IsUserWorker.php
... | ... | @@ -0,0 +1,19 @@ |
1 | +<?php | |
2 | + | |
3 | +namespace App\Http\Middleware; | |
4 | + | |
5 | +use App\Providers\RouteServiceProvider; | |
6 | +use Closure; | |
7 | +use Illuminate\Http\Request; | |
8 | +use Illuminate\Support\Facades\Auth; | |
9 | + | |
10 | +class IsUserWorker | |
11 | +{ | |
12 | + public function handle(Request $request, Closure $next) | |
13 | + { | |
14 | + if (Auth::user()->is_worker !== 1) { | |
15 | + return redirect(RouteServiceProvider::HOME); | |
16 | + } | |
17 | + return $next($request); | |
18 | + } | |
19 | +} |
app/Providers/RouteServiceProvider.php
... | ... | @@ -17,9 +17,9 @@ class RouteServiceProvider extends ServiceProvider |
17 | 17 | * |
18 | 18 | * @var string |
19 | 19 | */ |
20 | - public const HOME = '/home'; | |
20 | + public const HOME = '/'; | |
21 | 21 | |
22 | - public const LOGIN = '/login'; | |
22 | + public const LOGIN = '/'; | |
23 | 23 | |
24 | 24 | /** |
25 | 25 | * Define your route model bindings, pattern filters, and other route configuration. |
resources/views/chats/chats_list.blade.php
routes/web.php
... | ... | @@ -137,7 +137,7 @@ Route::group([ |
137 | 137 | Route::group([ |
138 | 138 | 'as' => 'admin.', // имя маршрута, например auth.index |
139 | 139 | 'prefix' => 'admin', // префикс маршрута, например auth/index |
140 | - 'middleware' => ['auth'], ['admin'], | |
140 | + 'middleware' => ['auth', 'admin'], | |
141 | 141 | ], function() { |
142 | 142 | |
143 | 143 | // выход |
... | ... | @@ -502,7 +502,7 @@ Route::get('cookies', function() { |
502 | 502 | Route::group([ |
503 | 503 | 'as' => 'worker.', // имя маршрута, например auth.index |
504 | 504 | 'prefix' => 'worker', // префикс маршрута, например auth/index |
505 | - 'middleware' => ['auth'], ['is_worker'], | |
505 | + 'middleware' => ['auth', 'is_worker'], | |
506 | 506 | ], function() { |
507 | 507 | // Формы редактирования |
508 | 508 | Route::get('cabinet/basic_information', [WorkerController::class, 'basic_information'])->name('basic_information'); |
... | ... | @@ -573,7 +573,7 @@ Route::group([ |
573 | 573 | Route::group([ |
574 | 574 | 'as' => 'employer.', // имя маршрута, например auth.index |
575 | 575 | 'prefix' => 'employer', // префикс маршрута, например auth/index |
576 | - 'middleware' => ['auth'], !['is_worker'], | |
576 | + 'middleware' => ['auth', 'is_employer'], | |
577 | 577 | ], function() { |
578 | 578 | // 0 страница - Личные данные работодателя |
579 | 579 | Route::get('cabinet/employer_info', [EmployerController::class, 'employer_info'])->name('employer_info'); |