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 @@