Skip to content

Commit

Permalink
clean after refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
temaotl committed Aug 1, 2024
1 parent 192a85c commit 7970dbc
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 40 deletions.
67 changes: 30 additions & 37 deletions app/Http/Controllers/FederationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,47 +112,40 @@ public function edit(Federation $federation)
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
* @return \Illuminate\Http\RedirectResponse
*/
public function update(UpdateFederation $request, Federation $federation)
{
switch (request('action')) {
case 'update':

$this->authorize('update', $federation);

$validated = $request->validated();

$id = $federation->name;
if (isset($validated['name'])) {
$id = generateFederationID($validated['name']);
}
$additionalFilters = $request->input('sp_and_ip_feed', 0);
$filters = $id;

if ($additionalFilters) {
$filters .= ', '.$id.'+idp';
$filters .= ', '.$id.'+sp';
}
$validated['filters'] = $filters;
$validated['additional_filters'] = $additionalFilters;

$federation->update($validated);

if (! $federation->wasChanged()) {
return redirect()
->route('federations.show', $federation);
}
NotificationService::sendModelNotification($federation, new FederationUpdated($federation));
// GitUpdateFederation::dispatch($federation, Auth::user());

return redirect()
->route('federations.show', $federation)
->with('status', __('federations.updated'));

default:
return redirect()->route('federations.show', $federation);
$this->authorize('update', $federation);

$validated = $request->validated();

$id = $federation->name;
if (isset($validated['name'])) {
$id = generateFederationID($validated['name']);
}
$additionalFilters = $request->input('sp_and_ip_feed', 0);
$filters = $id;

if ($additionalFilters) {
$filters .= ', '.$id.'+idp';
$filters .= ', '.$id.'+sp';
}
$validated['filters'] = $filters;
$validated['additional_filters'] = $additionalFilters;

$federation->update($validated);

if (! $federation->wasChanged()) {
return redirect()
->route('federations.show', $federation);
}
NotificationService::sendModelNotification($federation, new FederationUpdated($federation));
// GitUpdateFederation::dispatch($federation, Auth::user());

return redirect()
->route('federations.show', $federation)
->with('status', __('federations.updated'));
}

/**
Expand Down
1 change: 0 additions & 1 deletion resources/views/federations/partials/approve.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<form class="inline-block" action="{{ route('federations.approve', $federation) }}" method="POST">
@csrf
@method('post')
<input type="hidden" name="action" value="approve">
<x-button>{{ __('common.approve') }}</x-button>
</form>
1 change: 0 additions & 1 deletion resources/views/federations/partials/reject.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
<form class="inline-block" action="{{ route('federations.reject', $federation) }}" method="POST">
@csrf
@method('delete')
<input type="hidden" name="action" value="reject">
<x-button color="red">{{ __('common.reject') }}</x-button>
</form>
1 change: 0 additions & 1 deletion resources/views/federations/partials/state.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<form x-data="{ open: false }" class="inline-block" action="{{ route('federations.state', $federation) }}" method="POST">
@csrf
@method('patch')
<input type="hidden" name="action" value="state">

@if ($federation->trashed())
<x-button @click.prevent="open = !open" color="green">{{ __('common.restore') }}</x-button>
Expand Down

0 comments on commit 7970dbc

Please sign in to comment.