shaungbhone's avatar

Route URL

I am stuck with those for a long time. Please help me. I don't want to pass with this id in a URL like this. How can I do that?

http://127.0.0.1:8001/packages/27/edit?id=27

web.php

Route::post('packages/{package}', [PackageController::class, 'update'])->name('update.packages');
Route::get('packages/{package}/edit', [PackageController::class, 'edit'])->name('edit.packages');

controller.php

public function edit(Package $package)
    {
        return view('templates.webapp.' . getTemplate() . '.pages.packages.edit', [
            'creditTypes' => creditType::get(),
            'package' => $package,
        ]);
    }

public function update(Package $package, StorePackageRequest $request)
    {
        if (!Gate::allows('update-package', $package)) {
            abort(403);
        }
        $data = $request->validated();

        $data['site_id'] = auth()->user()->site_id;

        $package->update($data);

        return back()->withSuccess('Update Packages Successful');
    }

index.blade.php edit button and delete button

<td>
    <i data-id="{{ $package->id }}"
        data-route="{{ route('edit.packages', $package->id) }}"
            class="fa fa-pencil edit-me" aria-hidden="true"></i>
               <i data-id="{{ $package->id }}"
                  data-route="{{ route('destroy.packages', $package->id) }}"
                         class="fa fa-trash delete-me" aria-hidden="true"></i>
  </td>
0 likes
4 replies
MichalOravec's avatar

I don't see any related code which cause your issue.

1 like

Please or to participate in this conversation.