diff --git a/app/Http/Controllers/Admin/UsersController.php b/app/Http/Controllers/Admin/UsersController.php index e3cb058..2fd3c2c 100644 --- a/app/Http/Controllers/Admin/UsersController.php +++ b/app/Http/Controllers/Admin/UsersController.php @@ -7,6 +7,7 @@ use App\Http\Requests\BaseUserRequest; use App\Models\User; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Storage; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Style\Alignment; use PhpOffice\PhpSpreadsheet\Style\Border; @@ -66,8 +67,13 @@ class UsersController extends Controller public function add_store_bd(BaseUserRequest $request) { $params = $request->all(); + + if ($request->has('file')) { + $params['file'] = $request->file('file')->store('basedata', 'public'); + } + $user = User::create($params); - return redirect()->route('admin.worker-profile-add', ['user' => $user]); + return redirect()->route('admin.basedata'); } public function edit_bd(User $user) { @@ -76,6 +82,14 @@ class UsersController extends Controller public function update_bd(BaseUserRequest $request, User $user) { $params = $request->all(); + + if ($request->has('file')) { + if (!empty($user->file)) Storage::delete($user->file); + $params['file'] = $request->file('file')->store('basedata', 'public'); + } else { + if (!empty($user->image)) $params['file'] = $user->file; + } + $user->update($params); return redirect()->route('admin.basedata'); } @@ -124,7 +138,12 @@ class UsersController extends Controller 'rgb' => '808080' ] ], + 'outline' => array( + 'style' => Border::BORDER_THIN, + 'color' => array('rgb' => '000000') + ), ], + 'alignment' => [ 'horizontal' => Alignment::HORIZONTAL_CENTER, 'vertical' => Alignment::VERTICAL_CENTER, @@ -148,7 +167,7 @@ class UsersController extends Controller if (isset($user->jobtitles[0]->id)) { $activeWorksheet->setCellValue('A12', "Должность: " . $user->jobtitles[0]->name); } - + $activeWorksheet->getColumnDimension("A")->setWidth(100); $writer = new Xlsx($spreadsheet); header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); diff --git a/app/Models/ProgramEducation.php b/app/Models/ProgramEducation.php new file mode 100644 index 0000000..10686f2 --- /dev/null +++ b/app/Models/ProgramEducation.php @@ -0,0 +1,11 @@ +string('file', 255)->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('file'); + }); + } +}; diff --git a/database/migrations/2023_10_16_083006_alter_table_education.php b/database/migrations/2023_10_16_083006_alter_table_education.php new file mode 100644 index 0000000..5f1d250 --- /dev/null +++ b/database/migrations/2023_10_16_083006_alter_table_education.php @@ -0,0 +1,32 @@ +string('site', 255)->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('site', function (Blueprint $table) { + // + }); + } +}; diff --git a/database/migrations/2023_10_16_083120_create_program_education_table.php b/database/migrations/2023_10_16_083120_create_program_education_table.php new file mode 100644 index 0000000..48fadb4 --- /dev/null +++ b/database/migrations/2023_10_16_083120_create_program_education_table.php @@ -0,0 +1,37 @@ +id(); + $table->integer('education_id')->nullable(false); + $table->string('level')->nullable(); + $table->string('name', 255)->nullable(false); + $table->text('text')->nullable(); + $table->string('email', 255)->nullable(); + $table->string('telephone', 255); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('program_education'); + } +}; diff --git a/resources/views/admin/users/add.blade.php b/resources/views/admin/users/add.blade.php index 48a2516..91a3e31 100644 --- a/resources/views/admin/users/add.blade.php +++ b/resources/views/admin/users/add.blade.php @@ -4,7 +4,7 @@

Добавление пользователя в базу данных

-
+ @csrf @include('admin.users.form')
diff --git a/resources/views/admin/users/edit.blade.php b/resources/views/admin/users/edit.blade.php index a583512..3c5a75a 100644 --- a/resources/views/admin/users/edit.blade.php +++ b/resources/views/admin/users/edit.blade.php @@ -4,7 +4,7 @@

Редактирование пользователя в базу данных

-
+ @csrf @isset($user) @method('PUT') diff --git a/resources/views/admin/users/form.blade.php b/resources/views/admin/users/form.blade.php index 66e325e..85e9036 100644 --- a/resources/views/admin/users/form.blade.php +++ b/resources/views/admin/users/form.blade.php @@ -82,6 +82,22 @@ @enderror
+
+ + @endif + @isset($user->file) + Скачать + @else +

-

+ @endisset