Fix: Организация берётся из items_json
✅ organization_id из первого элемента items ✅ Удалена валидация organization_id ✅ index.blade.php обрабатывает NULL organization Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
parent
6833441514
commit
b01d8431c8
|
|
@ -58,7 +58,6 @@ class CourseRequestController extends Controller
|
||||||
Gate::authorize('create', CourseRequest::class);
|
Gate::authorize('create', CourseRequest::class);
|
||||||
|
|
||||||
$validated = $request->validate([
|
$validated = $request->validate([
|
||||||
'organization_id' => 'nullable|exists:organizations,id',
|
|
||||||
'status' => 'nullable|in:pending,approved,rejected',
|
'status' => 'nullable|in:pending,approved,rejected',
|
||||||
'note' => 'nullable|string',
|
'note' => 'nullable|string',
|
||||||
'items_json' => 'required|string',
|
'items_json' => 'required|string',
|
||||||
|
|
@ -81,8 +80,9 @@ class CourseRequestController extends Controller
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Определяем организацию из первого элемента или общую
|
// Берём organization_id из первого элемента или null
|
||||||
$organizationId = $validated['organization_id'] ?? null;
|
$firstItem = reset($items);
|
||||||
|
$organizationId = $firstItem['organization_id'] ?? null;
|
||||||
|
|
||||||
// Создаём заявку
|
// Создаём заявку
|
||||||
$courseRequest = CourseRequest::create([
|
$courseRequest = CourseRequest::create([
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
@forelse($requests as $request)
|
@forelse($requests as $request)
|
||||||
<tr>
|
<tr>
|
||||||
<td><strong>{{ $request->organization->name }}</strong></td>
|
<td><strong>{{ $request->organization?->name ?? 'Без организации' }}</strong></td>
|
||||||
<td>
|
<td>
|
||||||
@if($request->isPending())
|
@if($request->isPending())
|
||||||
<span class="badge bg-warning">Ожидает</span>
|
<span class="badge bg-warning">Ожидает</span>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue