fix last position and last admission id

This commit is contained in:
aslan 2024-06-11 10:18:38 +03:00
parent 97f4cd68e6
commit 73e6502e60
3 changed files with 13 additions and 3 deletions

View File

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

View File

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

View File

@ -1,3 +1,4 @@
@php use App\Helpers\PositionHelper; @endphp
@extends('layouts.admin_layout')
@section('content')
@auth()
@ -42,7 +43,7 @@
{{ Form::label('position', 'Позиция') }}
</div>
<div class="mt-2">
{{ Form::text('position', 0, ['class' => 'form-control']) }}
{{ Form::text('position', PositionHelper::document(), ['class' => 'form-control']) }}
</div>
<div>
@if ($errors->any())
@ -53,7 +54,7 @@
{{ Form::label('admission_id', 'Пункт экрана приема') }}
</div>
<div class="mt-2">
{{ Form::select('admission_id', $admissions, null, ['class' => 'form-select']) }}
{{ Form::select('admission_id', $admissions, $lastDocument->admission_id, ['class' => 'form-select']) }}
</div>
<div>
@if ($errors->any())