updated Externallink. Should be able to do crud
This commit is contained in:
parent
0adc1ebf02
commit
354a5952a7
|
@ -83,15 +83,13 @@ class ExternalLinkController extends Controller
|
|||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$data = $request->validate([
|
||||
"name" => "max:255",
|
||||
"link" => "max:255"
|
||||
]);
|
||||
$data = $request->all();
|
||||
|
||||
$id->update($data);
|
||||
$id->save();
|
||||
$link = ExternalLink::find($id);
|
||||
$link->update($data);
|
||||
$link->save();
|
||||
|
||||
return Response::detect("external-links.update");
|
||||
return Response::detect("external-links.update", [ "link" => $link]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -102,7 +100,8 @@ class ExternalLinkController extends Controller
|
|||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$id->delete();
|
||||
return Response::detect("external-links.destroy");
|
||||
$link = ExternalLink::find($id);
|
||||
$link->delete();
|
||||
return redirect()->route("external-links.index");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,17 +6,18 @@
|
|||
@endsection
|
||||
|
||||
@section("path")
|
||||
<a href="../external-links/edit.blade.php" class="text-white">Rediger Link</a> /
|
||||
<a href="{{route('external-links.edit', ['external_link' => $link])}}" class="text-white">Rediger Link</a> /
|
||||
@endsection
|
||||
|
||||
@section("content")
|
||||
<h1>Rediger Link:</h1>
|
||||
<form method="post" action="{{ route("external-links.edit", ['external_link' => $link]) }}">
|
||||
<form method="post" action="{{route("external-links.update", ["external_link" => $link])}}">
|
||||
@csrf
|
||||
@method("PUT")
|
||||
<label for="title">Titel:</label>
|
||||
<input type="text" name="title" id="title" required>
|
||||
<input value="{{$link->name}}" type="text" name="title" id="title" required>
|
||||
<label for="link">Linket:</label>
|
||||
<input type="text" name="link" id="link" required>
|
||||
<input value="{{$link->link}}" type="text" name="link" id="link" required>
|
||||
<input type="submit" class="btn btn-dark text-white" value="Rediger">
|
||||
</form>
|
||||
@endsection
|
||||
|
|
|
@ -21,8 +21,13 @@
|
|||
<tr>
|
||||
<th>{{$link->name}}</th>
|
||||
<th><a href="{{$link->link}}">{{$link->link}}</th>
|
||||
<td><a href=""><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td>
|
||||
<td><a href=""><img class="w-100" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></a></td>
|
||||
<td><a href="{{ route("external-links.edit", [ "external_link" => $link ]) }}"><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td>
|
||||
<td> <form method="post" action="{{ route("external-links.destroy", [ "external_link" => $link ]) }}" class="w-100">
|
||||
@csrf
|
||||
@method("delete")
|
||||
|
||||
<button class="w-100" type="submit"><img class="w-100" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></button>
|
||||
</form></td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
@endsection
|
||||
|
||||
@section("path")
|
||||
<a href="{{ route('external-links.index') }}" class="text-white">External link</a> /
|
||||
<a href="{{ route('external-links.edit', ["external_link" => $link]) }}" class="text-white">External link</a> /
|
||||
@endsection
|
||||
|
||||
@section("content")
|
||||
|
|
Loading…
Reference in New Issue