Commit 5d0fbf2b0d23dc9f0fc28a20771ee8f4005d1e60
1 parent
e6d602adb3
Exists in
master
fix workers register
Showing 4 changed files with 56 additions and 3 deletions Side-by-side Diff
app/Http/Controllers/WorkerController.php
... | ... | @@ -39,6 +39,7 @@ use Illuminate\Support\Facades\DB; |
39 | 39 | use Illuminate\Support\Facades\Hash; |
40 | 40 | use Illuminate\Support\Facades\Storage; |
41 | 41 | use Illuminate\Support\Facades\Validator; |
42 | +use Illuminate\Validation\Rule; | |
42 | 43 | use Illuminate\View\View; |
43 | 44 | use JsonException; |
44 | 45 | use PhpOffice\PhpSpreadsheet\Spreadsheet; |
... | ... | @@ -578,7 +579,14 @@ class WorkerController extends Controller |
578 | 579 | $rules = [ |
579 | 580 | 'surname' => ['required', 'string', 'max:255'], |
580 | 581 | 'name_man' => ['required', 'string', 'max:255'], |
581 | - 'email' => ['required', 'email', 'max:255', 'unique:users'], | |
582 | + 'email' => [ | |
583 | + 'required', | |
584 | + 'email', | |
585 | + 'max:255', | |
586 | + Rule::unique('users')->where(function ($query) { | |
587 | + $query->where('is_bd', 0); | |
588 | + }), | |
589 | + ], | |
582 | 590 | 'password' => ['required', 'string', 'min:6'], |
583 | 591 | 'password_confirmation' => ['required', 'same:password'], |
584 | 592 | 'politik' => ['required', 'accepted'], |
app/Models/User.php
... | ... | @@ -194,4 +194,17 @@ class User extends Authenticatable implements MustVerifyEmail |
194 | 194 | return null; |
195 | 195 | } |
196 | 196 | |
197 | + public function getJobSingleAttribute(): ?string | |
198 | + { | |
199 | + $position = $this->workers[0]?->position_work; | |
200 | + | |
201 | + if ($position) { | |
202 | + return Job_title::where('id', $position)->first()?->name; | |
203 | + } | |
204 | + | |
205 | + return null; | |
206 | + } | |
207 | + | |
208 | + | |
209 | + | |
197 | 210 | } |
database/migrations/2024_12_27_143936_remove_unique_index_from_users_table.php
... | ... | @@ -0,0 +1,32 @@ |
1 | +<?php | |
2 | + | |
3 | +use Illuminate\Database\Migrations\Migration; | |
4 | +use Illuminate\Database\Schema\Blueprint; | |
5 | +use Illuminate\Support\Facades\Schema; | |
6 | + | |
7 | +return new class extends Migration | |
8 | +{ | |
9 | + /** | |
10 | + * Run the migrations. | |
11 | + * | |
12 | + * @return void | |
13 | + */ | |
14 | + public function up() | |
15 | + { | |
16 | + Schema::table('users', function (Blueprint $table) { | |
17 | + $table->dropUnique('users_email_unique'); | |
18 | + }); | |
19 | + } | |
20 | + | |
21 | + /** | |
22 | + * Reverse the migrations. | |
23 | + * | |
24 | + * @return void | |
25 | + */ | |
26 | + public function down() | |
27 | + { | |
28 | + Schema::table('users', function (Blueprint $table) { | |
29 | + $table->unique('email', 'users_email_unique'); | |
30 | + }); | |
31 | + } | |
32 | +}; |
resources/views/admin/worker/index.blade.php