Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Nov 20, 2023
1 parent 4dcced6 commit 8ccbc99
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Http/Controllers/RelationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Cone\Root\Support\Alert;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
Expand Down Expand Up @@ -51,7 +52,7 @@ public function store(Request $request, Model $model): RedirectResponse

$field->handleFormRequest($request, $related);

return Redirect::to(sprintf('%s/s', $field->get))
return Redirect::to($field->relatedUrl($model, $related))
->with('alerts.relation-created', Alert::success(__('The relation has been created!')));
}

Expand Down Expand Up @@ -90,7 +91,7 @@ public function update(Request $request, Model $model, Model $related): Redirect

$field->handleFormRequest($request, $related);

return Redirect::back()
return Redirect::to($field->relatedUrl($model, $related))
->with('alerts.relation-updated', Alert::success(__('The relation has been updated!')));
}

Expand All @@ -101,9 +102,11 @@ public function destroy(Request $request, Model $model, Model $related): Redirec
{
$field = $request->route('field');

//
$trashed = class_uses_recursive(SoftDeletes::class) && $related->trashed();

return Redirect::to('')
$trashed ? $related->forceDelete() : $related->delete();

return Redirect::to($field->modelUrl($model))
->with('alerts.relation-deleted', Alert::success(__('The relation has been deleted!')));
}
}

0 comments on commit 8ccbc99

Please sign in to comment.