diff --git a/app/Helpers/PositionHelper.php b/app/Helpers/PositionHelper.php index 94e9953..bfc74ab 100644 --- a/app/Helpers/PositionHelper.php +++ b/app/Helpers/PositionHelper.php @@ -4,6 +4,7 @@ namespace App\Helpers; use App\Models\Direction; use App\Models\DirectionProfile; +use App\Models\Document; use App\Models\EntranceExamination; use App\Models\ExaminationType; use App\Models\Faculty; @@ -66,4 +67,10 @@ class PositionHelper $maxPosition = EntranceExamination::max('position'); return $maxPosition >= 254 ? 255 : $maxPosition + 1; } + + public static function document() + { + $maxPosition = Document::max('position'); + return $maxPosition >= 254 ? 255 : $maxPosition + 1; + } } diff --git a/app/Http/Controllers/admin/DocumentController.php b/app/Http/Controllers/admin/DocumentController.php index be85d94..54b65ec 100644 --- a/app/Http/Controllers/admin/DocumentController.php +++ b/app/Http/Controllers/admin/DocumentController.php @@ -24,7 +24,9 @@ class DocumentController extends Controller public function create(): View|Application|Factory|\Illuminate\Contracts\Foundation\Application { $admissions = Admission::pluck('name', 'id'); - return view('admin.documents.create', compact('admissions')); + $lastDocument = Document::latest()->first(); +// dd($lastDocument->admission_id); + return view('admin.documents.create', compact('admissions', 'lastDocument')); } public function store(StoreDocumentRequest $request): RedirectResponse diff --git a/resources/views/admin/documents/create.blade.php b/resources/views/admin/documents/create.blade.php index 3728c7f..0c3c19c 100644 --- a/resources/views/admin/documents/create.blade.php +++ b/resources/views/admin/documents/create.blade.php @@ -1,3 +1,4 @@ +@php use App\Helpers\PositionHelper; @endphp @extends('layouts.admin_layout') @section('content') @auth() @@ -42,7 +43,7 @@ {{ Form::label('position', 'Позиция') }}