Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

livewire form not working #908

Open
AlizHarb opened this issue Sep 15, 2024 · 0 comments
Open

livewire form not working #908

AlizHarb opened this issue Sep 15, 2024 · 0 comments

Comments

@AlizHarb
Copy link

Hello
I'm unable to call any method from the livewire component

<?php

use Illuminate\Support\Facades\Route;
use App\Livewire;

Route::middleware([
    'auth:sanctum',
    config('jetstream.auth_session'),
    'verified',
])->group(function () {
    Route::prefix(\Mcamara\LaravelLocalization\Facades\LaravelLocalization::setLocale())
        ->middleware(['localeSessionRedirect', 'localizationRedirect', 'localeViewPath'])
        ->group(function () {

            // Dashboard
            Route::get('/', Livewire\Pages\Dashboard::class)->name('dashboard');

            // Game Routes
            Route::prefix('game')->group(function () {

                // Crimes
                Route::get('/crimes', Livewire\Game\Crimes::class)->name('crimes');

                // Inventory
                Route::get('/inventory', Livewire\Game\Inventory::class)->name('inventory');
            });

            // Livewire Routes
            \Livewire\Livewire::setUpdateRoute(function ($handle) {
                return Route::post('/livewire/update', $handle);
            });
        });
});
<form wire:submit.prevent="commit({{ $crime->id }})" class="mt-3">
                            <x-button type="submit" class="w-full py-2 px-4 h-10 text-center flex justify-center space-x-2 items-center" wire:loading.attr="disabled">
                                <span wire:loading.remove>{{ __('Commit') }}</span>
                                <span wire:loading>
                                    {{ __('Committing...') }}
                                </span>
                            </x-button>
                        </form>
<?php

namespace App\Livewire\Game;

use Illuminate\Support\Facades\Redirect;
use Livewire\Component;
use Masmerise\Toaster\Toastable;

class Crimes extends Component
{
    use Toastable;

    public function render()
    {
        $location = auth()->user()->character->location;

        return view('game.crimes', compact('location'))
                ->title(__('crimes.title'));
    }

    public function commit(int $crimeId): Redirect
    {
        flash('The crime has been committed.')->success();
        $this->warning('The quantity on hand is critically low.');

        return $this->redirect(route('crimes'));
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant