From 96681864eeb520fc2c9adf4507da38610e460119 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: Tue, 17 Oct 2023 14:07:28 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BF=D1=80=D0=B0=D0=B2=D0=BE=D1=87=D0=BD=D0?= =?UTF-8?q?=B8=D0=BA=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B8=20=D0=BF=D1=80=D0=BE=D0=B3=D1=80=D0=B0=D0=BC?= =?UTF-8?q?=D0=BC=D1=8B=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B7=D0=BE=D0=B2=D0=B0=D0?= =?UTF-8?q?=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Admin/EducationController.php | 23 +++++++- app/Http/Requests/JobTitlesRequest.php | 2 +- app/Http/Requests/ProgramEducationRequest.php | 34 +++++++++++ app/Models/ProgramEducation.php | 10 ++++ ...10_16_083120_create_program_education_table.php | 2 +- resources/views/admin/education/form.blade.php | 59 +++++++++++++++++++- resources/views/admin/education/program.blade.php | 45 +++++++++++++++ resources/views/admin/pages/form.blade.php | 4 +- routes/web.php | 3 + 9 files changed, 176 insertions(+), 6 deletions(-) create mode 100644 app/Http/Requests/ProgramEducationRequest.php create mode 100644 resources/views/admin/education/program.blade.php diff --git a/app/Http/Controllers/Admin/EducationController.php b/app/Http/Controllers/Admin/EducationController.php index 21669b7..e45ea75 100644 --- a/app/Http/Controllers/Admin/EducationController.php +++ b/app/Http/Controllers/Admin/EducationController.php @@ -4,7 +4,9 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; use App\Http\Requests\EducationRequest; +use App\Http\Requests\ProgramEducationRequest; use App\Models\Education; +use App\Models\ProgramEducation; use Illuminate\Http\Request; use Illuminate\Support\Facades\Storage; @@ -68,8 +70,14 @@ class EducationController extends Controller */ public function edit(Education $education) { + $program1 = ProgramEducation::query()->where('education_id', '=', $education->id) + ->where('level', '=', '1')->get(); + $program2 = ProgramEducation::query()->where('education_id', '=', $education->id) + ->where('level', '=', '2')->get(); + $program3 = ProgramEducation::query()->where('education_id', '=', $education->id) + ->where('level', '=', '3')->get(); - return view('admin.education.edit', compact('education')); + return view('admin.education.edit', compact('education', 'program1', 'program2', 'program3')); } /** @@ -104,4 +112,17 @@ class EducationController extends Controller $education->update(['is_remove' => 1]); return redirect()->route('admin.education.index'); } + + public function add_program(Education $education, int $level) { + $id_education = $education->id; + return view('admin.education.program', compact('id_education', 'level')); + } + + public function store_program(ProgramEducationRequest $request) { + $education = $request->education_id; + ProgramEducation::create($request->all()); + + return redirect()->route('admin.education.edit', ['education' => $education]); + } + } diff --git a/app/Http/Requests/JobTitlesRequest.php b/app/Http/Requests/JobTitlesRequest.php index 11b4339..e8edb01 100644 --- a/app/Http/Requests/JobTitlesRequest.php +++ b/app/Http/Requests/JobTitlesRequest.php @@ -27,7 +27,7 @@ class JobTitlesRequest extends FormRequest 'name' => [ 'required', 'min:3', - 'max:100', + 'max:255', ], 'parent_id' => [ 'numeric', diff --git a/app/Http/Requests/ProgramEducationRequest.php b/app/Http/Requests/ProgramEducationRequest.php new file mode 100644 index 0000000..71435f0 --- /dev/null +++ b/app/Http/Requests/ProgramEducationRequest.php @@ -0,0 +1,34 @@ + + */ + public function rules() + { + return [ + 'name' => [ + 'required', + 'min:3', + 'max:255', + ], + ]; + } +} diff --git a/app/Models/ProgramEducation.php b/app/Models/ProgramEducation.php index 10686f2..58d0580 100644 --- a/app/Models/ProgramEducation.php +++ b/app/Models/ProgramEducation.php @@ -8,4 +8,14 @@ use Illuminate\Database\Eloquent\Model; class ProgramEducation extends Model { use HasFactory; + + protected $fillable = [ + 'id', + 'name', + 'education_id', + 'text', + 'email', + 'telephone', + 'level', + ]; } 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 index 48fadb4..55b2b69 100644 --- a/database/migrations/2023_10_16_083120_create_program_education_table.php +++ b/database/migrations/2023_10_16_083120_create_program_education_table.php @@ -20,7 +20,7 @@ return new class extends Migration $table->string('name', 255)->nullable(false); $table->text('text')->nullable(); $table->string('email', 255)->nullable(); - $table->string('telephone', 255); + $table->string('telephone', 255)->nullable(); $table->timestamps(); }); } diff --git a/resources/views/admin/education/form.blade.php b/resources/views/admin/education/form.blade.php index cb3a0cd..d35a3c1 100644 --- a/resources/views/admin/education/form.blade.php +++ b/resources/views/admin/education/form.blade.php @@ -59,7 +59,7 @@
+ + @isset($education) +
+ + + + + + +
+ Добавить специализацию
+ @if ((isset($program1)) && ($program1->count())) + @foreach ($program1 as $prog1) +

+ @endforeach + @else + Нет записей + @endif +
+
+ Добавить специализацию
+ @if ((isset($program2)) && ($program2->count())) + @foreach ($program2 as $prog2) +

+ @endforeach + @else + Нет записей + @endif +
+
+ Добавить специализацию
+ @if ((isset($program3)) && ($program3->count())) + @foreach ($program3 as $prog3) +

+ @endforeach + @else + Нет записей + @endif +
+

+ @endisset +
+
+
+ + + +@endsection diff --git a/resources/views/admin/pages/form.blade.php b/resources/views/admin/pages/form.blade.php index e3dc74f..5ff1252 100644 --- a/resources/views/admin/pages/form.blade.php +++ b/resources/views/admin/pages/form.blade.php @@ -75,7 +75,7 @@