Commit 0961cd3e6075f5cfb89de83771b5406eb43a7c15
1 parent
313a7a8059
Exists in
master
and in
1 other branch
Модель программы образования, прикрепление анкет соискателям
Showing 10 changed files with 160 additions and 7 deletions Side-by-side Diff
- app/Http/Controllers/Admin/UsersController.php
- app/Models/ProgramEducation.php
- app/Models/User.php
- database/migrations/2023_10_16_082838_alter_table_users.php
- database/migrations/2023_10_16_083006_alter_table_education.php
- database/migrations/2023_10_16_083120_create_program_education_table.php
- resources/views/admin/users/add.blade.php
- resources/views/admin/users/edit.blade.php
- resources/views/admin/users/form.blade.php
- resources/views/admin/users/index_bd.blade.php
app/Http/Controllers/Admin/UsersController.php
... | ... | @@ -7,6 +7,7 @@ use App\Http\Requests\BaseUserRequest; |
7 | 7 | use App\Models\User; |
8 | 8 | use Illuminate\Http\Request; |
9 | 9 | use Illuminate\Support\Facades\Auth; |
10 | +use Illuminate\Support\Facades\Storage; | |
10 | 11 | use PhpOffice\PhpSpreadsheet\Spreadsheet; |
11 | 12 | use PhpOffice\PhpSpreadsheet\Style\Alignment; |
12 | 13 | use PhpOffice\PhpSpreadsheet\Style\Border; |
... | ... | @@ -66,8 +67,13 @@ class UsersController extends Controller |
66 | 67 | |
67 | 68 | public function add_store_bd(BaseUserRequest $request) { |
68 | 69 | $params = $request->all(); |
70 | + | |
71 | + if ($request->has('file')) { | |
72 | + $params['file'] = $request->file('file')->store('basedata', 'public'); | |
73 | + } | |
74 | + | |
69 | 75 | $user = User::create($params); |
70 | - return redirect()->route('admin.worker-profile-add', ['user' => $user]); | |
76 | + return redirect()->route('admin.basedata'); | |
71 | 77 | } |
72 | 78 | |
73 | 79 | public function edit_bd(User $user) { |
... | ... | @@ -76,6 +82,14 @@ class UsersController extends Controller |
76 | 82 | |
77 | 83 | public function update_bd(BaseUserRequest $request, User $user) { |
78 | 84 | $params = $request->all(); |
85 | + | |
86 | + if ($request->has('file')) { | |
87 | + if (!empty($user->file)) Storage::delete($user->file); | |
88 | + $params['file'] = $request->file('file')->store('basedata', 'public'); | |
89 | + } else { | |
90 | + if (!empty($user->image)) $params['file'] = $user->file; | |
91 | + } | |
92 | + | |
79 | 93 | $user->update($params); |
80 | 94 | return redirect()->route('admin.basedata'); |
81 | 95 | } |
... | ... | @@ -124,7 +138,12 @@ class UsersController extends Controller |
124 | 138 | 'rgb' => '808080' |
125 | 139 | ] |
126 | 140 | ], |
141 | + 'outline' => array( | |
142 | + 'style' => Border::BORDER_THIN, | |
143 | + 'color' => array('rgb' => '000000') | |
144 | + ), | |
127 | 145 | ], |
146 | + | |
128 | 147 | 'alignment' => [ |
129 | 148 | 'horizontal' => Alignment::HORIZONTAL_CENTER, |
130 | 149 | 'vertical' => Alignment::VERTICAL_CENTER, |
... | ... | @@ -148,7 +167,7 @@ class UsersController extends Controller |
148 | 167 | if (isset($user->jobtitles[0]->id)) { |
149 | 168 | $activeWorksheet->setCellValue('A12', "Должность: " . $user->jobtitles[0]->name); |
150 | 169 | } |
151 | - | |
170 | + $activeWorksheet->getColumnDimension("A")->setWidth(100); | |
152 | 171 | $writer = new Xlsx($spreadsheet); |
153 | 172 | |
154 | 173 | header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); |
app/Models/ProgramEducation.php
app/Models/User.php
database/migrations/2023_10_16_082838_alter_table_users.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->string('file', 255)->nullable(); | |
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->dropColumn('file'); | |
30 | + }); | |
31 | + } | |
32 | +}; |
database/migrations/2023_10_16_083006_alter_table_education.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('education', function (Blueprint $table) { | |
17 | + $table->string('site', 255)->nullable(); | |
18 | + }); | |
19 | + } | |
20 | + | |
21 | + /** | |
22 | + * Reverse the migrations. | |
23 | + * | |
24 | + * @return void | |
25 | + */ | |
26 | + public function down() | |
27 | + { | |
28 | + Schema::table('site', function (Blueprint $table) { | |
29 | + // | |
30 | + }); | |
31 | + } | |
32 | +}; |
database/migrations/2023_10_16_083120_create_program_education_table.php
... | ... | @@ -0,0 +1,37 @@ |
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::create('program_education', function (Blueprint $table) { | |
17 | + $table->id(); | |
18 | + $table->integer('education_id')->nullable(false); | |
19 | + $table->string('level')->nullable(); | |
20 | + $table->string('name', 255)->nullable(false); | |
21 | + $table->text('text')->nullable(); | |
22 | + $table->string('email', 255)->nullable(); | |
23 | + $table->string('telephone', 255); | |
24 | + $table->timestamps(); | |
25 | + }); | |
26 | + } | |
27 | + | |
28 | + /** | |
29 | + * Reverse the migrations. | |
30 | + * | |
31 | + * @return void | |
32 | + */ | |
33 | + public function down() | |
34 | + { | |
35 | + Schema::dropIfExists('program_education'); | |
36 | + } | |
37 | +}; |
resources/views/admin/users/add.blade.php
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 | <h4 class="mb-4 text-lg font-semibold text-gray-600 dark:text-gray-300"> |
5 | 5 | Добавление пользователя в базу данных |
6 | 6 | </h4> |
7 | - <form method="POST" action="{{ route('admin.add-store-basedata') }}"> | |
7 | + <form method="POST" action="{{ route('admin.add-store-basedata') }}" enctype="multipart/form-data"> | |
8 | 8 | @csrf |
9 | 9 | @include('admin.users.form') |
10 | 10 | </form> |
resources/views/admin/users/edit.blade.php
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 | <h4 class="mb-4 text-lg font-semibold text-gray-600 dark:text-gray-300"> |
5 | 5 | Редактирование пользователя в базу данных |
6 | 6 | </h4> |
7 | - <form method="POST" action="{{ route('admin.update-basedata', ['user' => $user->id]) }}"> | |
7 | + <form method="POST" action="{{ route('admin.update-basedata', ['user' => $user->id]) }}" enctype="multipart/form-data"> | |
8 | 8 | @csrf |
9 | 9 | @isset($user) |
10 | 10 | @method('PUT') |
resources/views/admin/users/form.blade.php
... | ... | @@ -82,6 +82,22 @@ |
82 | 82 | @enderror |
83 | 83 | </label><br> |
84 | 84 | |
85 | + <label class="block text-sm"> | |
86 | + <span class="text-gray-700 dark:text-gray-400">Файл-анкета</span> | |
87 | + <input type="file" class="block w-full mt-1 text-sm dark:border-gray-600 dark:bg-gray-700 | |
88 | + focus:border-purple-400 focus:outline-none focus:shadow-outline-purple | |
89 | + dark:text-gray-300 dark:focus:shadow-outline-gray form-input" | |
90 | + id="file" name="file"> | |
91 | + @error('file') | |
92 | + <span class="text-xs text-red-600 dark:text-red-400"> | |
93 | + {{ $message }} | |
94 | + </span> | |
95 | + @enderror | |
96 | + @isset($user->file) | |
97 | + <a class="text-gray-700 dark:text-gray-400" target="blank" href="{{ asset(Storage::url($user->file)) }}">{{ $user->file }}</a> | |
98 | + @endisset | |
99 | + </label><br> | |
100 | + | |
85 | 101 | <!--<label class="block text-sm"> |
86 | 102 | |
87 | 103 | <input type="hidden" name="page_worker" value="0" /> |
resources/views/admin/users/index_bd.blade.php
... | ... | @@ -130,9 +130,14 @@ |
130 | 130 | |
131 | 131 | <td class="px-4 py-3 text-sm"> |
132 | 132 | @if (isset($user->workers[0]->id)) |
133 | - <a href="{{ route('admin.worker-profile-edit', ['worker' => $user->workers[0]->id]) }}">Править</a> | | |
134 | - <a href="{{ route('admin.doc-basedata', ['user' => $user->id]) }}">Скачать</a> | |
133 | + <!--<a href="{{ route('admin.worker-profile-edit', ['worker' => $user->workers[0]->id]) }}">Править</a> |--> | |
134 | + <!--<a href="{{ route('admin.doc-basedata', ['user' => $user->id]) }}">Скачать</a>--> | |
135 | 135 | @endif |
136 | + @isset($user->file) | |
137 | + <a class="text-gray-700 dark:text-gray-400" target="blank" href="{{ asset(Storage::url($user->file)) }}">Скачать</a> | |
138 | + @else | |
139 | + <p class="text-gray-700 dark:text-gray-400">-</p> | |
140 | + @endisset | |
136 | 141 | </td> |
137 | 142 | |
138 | 143 | <td class="px-4 py-3 text-sm"> |