Bulletinboard/resources/views/admin/show-post.blade.php

108 lines
5.3 KiB
PHP

<x-layout>
<div class="container">
@isset($success)
<div class="alert alert-success" role="alert">{{ $success }}</div>
@endisset
@isset($post)
<div class="card rounded shadow mt-2 mr-5 ml-5">
<div class="card-body">
<h2>Rediger Opslag</h2>
<form action="" method="post" enctype="multipart/form-data">
@method("put")
@csrf
<div class="mb-3">
<label for="title" class="form-label">Titel</label>
<input type="text" class="form-control" id="title" name="title" value="{{ $post->title }}" required>
@error('title')
{{ $message }}
@enderror
</div>
<div class="mb-3">
<label for="occupation" class="form-label">Stilling</label>
<select id="occupation" class="form-control" name="occupation_id">
@foreach($occupations as $occupation)
@if($occupation->id == $post->occupation->id)
<option value="{{ $occupation->id }}" selected>{{ $occupation->name }}</option>
@else
<option value="{{ $occupation->id }}">{{ $occupation->name }}</option>
@endif
@endforeach
</select>
@error('occupation_id')
{{ $message }}
@enderror
</div>
<div class="mb-3">
<label for="text">Beskrivelse</label>
<textarea name="text" id="text" style="width: 100%; height: 150px;">{{ $post->text }}</textarea>
@error('text')
{{ $message }}
@enderror
</div>
<div class="mb-3">
<label for="file">Upload (valgfri)</label>
<input type="file" class="form-control" id="file" name="file">
@error('file')
{{ $message }}
@enderror
</div>
<div class="mb-3">
<label for="state">Status</label>
<select id="state" class="form-control" name="state_id">
@foreach($states as $state)
@if($state->id == $post->status->id)
<option value="{{ $state->id }}" selected>{{ $state->name }}</option>
@else
<option value="{{ $state->id }}">{{ $state->name }}</option>
@endif
@endforeach
</select>
@error('state_id')
{{ $message }}
@enderror
</div>
<div class="row mb-3">
<div class="col">
<label for="time">Tid</label>
<input type="number" class="form-control" id="time" name="time" value="{{ $post->time }}" required>
@error('time')
{{ $message }}
@enderror
</div>
<div class="col">
<label for="format">Format</label>
<select id="format" class="form-control" name="time_period_id">
@foreach($formats as $format)
@if($format->id == $post->timePeriod->id)
<option value="{{ $format->id }}" selected>{{ $format->name }}</option>
@else
<option value="{{ $format->id }}">{{ $format->name }}</option>
@endif
@endforeach
</select>
@error('time_period_id')
{{ $message }}
@enderror
</div>
</div>
<button type="submit" class="btn btn-primary">Opdater</button>
</form>
<form action="/admin/posts/{{ $post->id }}" method="post">
@csrf
@method("DELETE")
<p>ADVARSEL: Du kan IKKE gendanne slettede opslag!</p>
<button class="btn btn-danger" type="submit">Slet</button>
</form>
</div>
</div>
@endisset
</div>
</x-layout>