Skip to content

Instantly share code, notes, and snippets.

@reinink
Last active March 12, 2021 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reinink/60f47df1257ee5d2100803ec94784b04 to your computer and use it in GitHub Desktop.
Save reinink/60f47df1257ee5d2100803ec94784b04 to your computer and use it in GitHub Desktop.
Toggle.md
// Option 1: Manually
this.$inertia.post(`/toggle-thing/${this.user.id}`, {}, { preserveScroll: true })
<!-- Option 2: Inertia Link -->
<inertia-link :href="`/toggle-thing/${user.id}`" preserve-scroll>Toggle</inertia-link>
use Illuminate\Support\Facades\Redirect;

class ToggleController extends Controller
{
    public function update(User $user)
    {
        $user->toggleThing();

        return Redirect::back();
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment