From 0961cd3e6075f5cfb89de83771b5406eb43a7c15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=20=D0=9B=D0=B0=D1=80?= =?UTF-8?q?=D0=B8=D0=BE=D0=BD=D0=BE=D0=B2?= Date: Mon, 16 Oct 2023 18:18:08 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9C=D0=BE=D0=B4=D0=B5=D0=BB=D1=8C=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D0=B3=D1=80=D0=B0=D0=BC=D0=BC=D1=8B=20=D0=BE=D0=B1=D1=80=D0?= =?UTF-8?q?=B0=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F,=20=D0=BF=D1=80=D0=B8?= =?UTF-8?q?=D0=BA=D1=80=D0=B5=D0=BF=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B0=D0?= =?UTF-8?q?=BD=D0=BA=D0=B5=D1=82=20=D1=81=D0=BE=D0=B8=D1=81=D0=BA=D0=B0=D1=82?= =?UTF-8?q?=D0=B5=D0=BB=D1=8F=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Admin/UsersController.php | 23 ++++++++++-- app/Models/ProgramEducation.php | 11 ++++++ app/Models/User.php | 3 +- .../2023_10_16_082838_alter_table_users.php | 32 +++++++++++++++++ .../2023_10_16_083006_alter_table_education.php | 32 +++++++++++++++++ ...10_16_083120_create_program_education_table.php | 37 ++++++++++++++++++++ resources/views/admin/users/add.blade.php | 2 +- resources/views/admin/users/edit.blade.php | 2 +- resources/views/admin/users/form.blade.php | 16 +++++++++ resources/views/admin/users/index_bd.blade.php | 9 +++-- 10 files changed, 160 insertions(+), 7 deletions(-) create mode 100644 app/Models/ProgramEducation.php create mode 100644 database/migrations/2023_10_16_082838_alter_table_users.php create mode 100644 database/migrations/2023_10_16_083006_alter_table_education.php create mode 100644 database/migrations/2023_10_16_083120_create_program_education_table.php 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 -- 1.7.10.4