1
0
tinklu-it-projektas/resources/views/tests/edit.blade.php
2023-10-29 21:41:27 +02:00

84 lines
4.1 KiB
PHP

<x-app-layout>
<div class="max-w-2xl mx-auto p-4 sm:p-6 lg:p-8">
<form method="POST" action="{{ route('tests.update', $test) }}">
@csrf
@method("patch")
<div class="flex flex-col gap-1">
<x-input-label>{{ __("Name") }}</x-input-label>
<x-text-input name="name" placeholder="{{ __('Name') }}" value="{{ old('name', $test->name) }}" />
<x-input-error :messages="$errors->get('name')" class="mt-2" />
</div>
<div class="mt-4 space-x-2">
<x-primary-button>{{ __("Save") }}</x-primary-button>
<a href="{{ route('tests.index') }}">{{ __("Cancel") }}</a>
</div>
</form>
<hr class="mt-6 mb-6">
<form method="POST" action="{{ route('questions.store') }}">
@csrf
<div class="flex flex-col gap-1">
<input type="hidden" value="{{ $test->id }}" name="test_id">
<x-input-label>{{ __("Question") }}</x-input-label>
<x-text-input name="question" placeholder="{{ __('Question') }}" value="{{ old('question') }}" />
<x-input-error :messages="$errors->get('question')" class="mt-2" />
<x-input-label>{{ __("Answer") }}</x-input-label>
<x-text-input name="answer" placeholder="{{ __('Answer') }}" value="{{ old('answer') }}" />
<x-input-error :messages="$errors->get('answer')" class="mt-2" />
<x-input-label>{{ __("Points") }}</x-input-label>
<x-text-input name="points" placeholder="{{ __('Points') }}" value="{{ old('points', 1) }}" />
<x-input-error :messages="$errors->get('points')" class="mt-2" />
</div>
<div class="mt-4 space-x-2">
<x-primary-button>{{ __("Add question") }}</x-primary-button>
</div>
</form>
<table class="mt-6 border border-gray-300 w-full text-left">
<tr>
<th class="border border-gray-300 p-1">{{ __("Question") }}</th>
<th class="border border-gray-300 p-1">{{ __("Answer") }}</th>
<th class="border border-gray-300 p-1">{{ __("Points") }}</th>
<th class="border border-gray-300 p-1"></th>
</tr>
@foreach ($test->questions()->get() as $question)
<tr>
<td class="border border-gray-300 p-1">{{ $question->question }}</td>
<td class="border border-gray-300 p-1">{{ $question->answer }}</td>
<td class="border border-gray-300 p-1">{{ $question->points }}</td>
<td class="border border-gray-300 p-1">
<x-dropdown>
<x-slot name="trigger">
<button>
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 text-gray-400" viewBox="0 0 20 20" fill="currentColor">
<path d="M6 10a2 2 0 11-4 0 2 2 0 014 0zM12 10a2 2 0 11-4 0 2 2 0 014 0zM16 12a2 2 0 100-4 2 2 0 000 4z" />
</svg>
</button>
</x-slot>
<x-slot name="content">
<x-dropdown-link :href="route('questions.edit', $question)">
{{ __("Edit") }}
</x-dropdown-link>
<form method="POST" action="{{ route("questions.destroy", $question) }}">
@csrf
@method("delete")
<x-dropdown-link :href="route('questions.destroy', $question)" onclick="event.preventDefault(); this.closest('form').submit();">
{{ __("Delete") }}
</x-dropdown-link>
</form>
</x-slot>
</x-dropdown>
</td>
</tr>
@endforeach
</table>
</div>
</x-app-layout>