Modified EventController.php.
This commit is contained in:
parent
a3209bc422
commit
66e8b2e3d8
|
@ -70,9 +70,10 @@ class EventController extends Controller
|
|||
* @param int $id
|
||||
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function edit(Event $id)
|
||||
public function edit($id)
|
||||
{
|
||||
return Response::detect("events.edit", [ "event" => $id ]);
|
||||
$event = Event::find($id);
|
||||
return Response::detect("events.edit", [ "event" => $event ]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -82,17 +83,15 @@ class EventController extends Controller
|
|||
* @param int $id
|
||||
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function update(Request $request, Event $id)
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$requestBody = $request->validate([
|
||||
"name" => "unique:events|max:255",
|
||||
"description" => "max:255"
|
||||
]);
|
||||
$data = $request->all();
|
||||
|
||||
$id->update($requestBody);
|
||||
$id->save();
|
||||
$event = Event::find($id);
|
||||
$event->update($data);
|
||||
$event->save();
|
||||
|
||||
return Response::detect("events.update");
|
||||
return Response::detect("events.update", [ "event" => $event]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
@endsection
|
||||
|
||||
@section("path")
|
||||
<a href="" class="text-white">Vis Events</a> /
|
||||
<a href="{{route("events.edit", ["event" => $event])}}" class="text-white">Vis Events</a> /
|
||||
@endsection
|
||||
|
||||
@section("content")
|
||||
|
@ -14,10 +14,13 @@
|
|||
<form method="post" action="{{route("events.update", ["event" => $event])}}">
|
||||
@csrf
|
||||
@method("PUT")
|
||||
<label for="title">Titel:</label>
|
||||
<input value="{{$event->name}}" type="text" name="title" id="title" required>
|
||||
<label for="link">Linket:</label>
|
||||
<input value="{{$event->description}}" type="text" name="link" id="link" required>
|
||||
<label for="event_title">Event Titel:</label>
|
||||
<input value="{{$event->name}}" type="text" name="name" id="event_title" required>
|
||||
<label for="description">Beskrivelse</label>
|
||||
<input value="{{$event->description}}" type="text" name="description" id="description" required>
|
||||
<label for="date">Beskrivelse</label>
|
||||
<input value="{{$event->date}}" type="date" name="date" id="date" required>
|
||||
|
||||
<input type="submit" class="btn btn-dark text-white" value="Rediger">
|
||||
</form>
|
||||
@endsection
|
||||
|
|
Loading…
Reference in New Issue