forked from aslan/applicant-site
fix last position and last admission id
This commit is contained in:
parent
97f4cd68e6
commit
73e6502e60
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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())
|
||||
|
|
Loading…
Reference in New Issue