wire-elements / spotlight

Livewire component that brings Spotlight/Alfred-like functionality to your Laravel application.
MIT License
927 stars 72 forks source link

Target [Illuminate\Contracts\Auth\StatefulGuard] is not instantiable. #38

Closed sandy15d closed 3 years ago

sandy15d commented 3 years ago

`<?php

namespace LivewireUI\Spotlight\Commands;

use Illuminate\Contracts\Auth\StatefulGuard; use LivewireUI\Spotlight\Spotlight; use LivewireUI\Spotlight\SpotlightCommand;

class Logout extends SpotlightCommand {

protected string $name = 'Logout';
protected string $description = 'Logout out of your account';
public function execute(Spotlight $spotlight, StatefulGuard $guard): void

{

    $guard->logout();

    $spotlight->redirect('/');

}

} `

PhiloNL commented 3 years ago

Works just fine here.

sandy15d commented 3 years ago

but when i click on logout this kind of error arrives

Target [Illuminate\Contracts\Auth\StatefulGuard] is not instantiable.

PhiloNL commented 3 years ago

Not sure, if you create a fresh installation of Laravel with Spotlight installed, reproduce the problem and share this via a Github repository I can take a look.

modernben commented 2 years ago

I'm getting this as well on a project that uses the laravel/ui package.

Laravel: 8.73.2 PHP: 7.4.26 Laravel UI: ^3.3

modernben commented 2 years ago

I created my own and changed it to auth()->logout() and it works

sandy15d commented 2 years ago

Hi Ben...

Pls Can you share full code if possible...

It will be very helpful for me

On Fri, 3 Dec, 2021, 8:03 pm Ben Miller, @.***> wrote:

I'm getting this as well on a project that uses the laravel/ui package.

Laravel: 8.73.2 PHP: 7.4.26 Laravel UI: ^3.3

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/wire-elements/spotlight/issues/38#issuecomment-985568640, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIBYSTW2MZKWHZVFRDBVMSTUPDIMJANCNFSM5CJS65FA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

modernben commented 2 years ago

@sandy15d

<?php

namespace App\Spotlight;

use LivewireUI\Spotlight\Spotlight;
use LivewireUI\Spotlight\SpotlightCommand;
use Illuminate\Contracts\Auth\StatefulGuard;
use LivewireUI\Spotlight\SpotlightSearchResult;
use LivewireUI\Spotlight\SpotlightCommandDependency;
use LivewireUI\Spotlight\SpotlightCommandDependencies;

class Logout extends SpotlightCommand
{
    protected string $name = 'Logout';

    protected string $description = 'Logout out of your account';

    public function execute(Spotlight $spotlight): void
    {
        auth()->logout();
        $spotlight->redirect('/');
    }
}

Then update config/livewire-ui-spotlight.php

'commands' => [
    App\Spotlight\Logout::class,
],
am-chris commented 2 years ago

I also just ran into this issue after upgrading from Laravel 6 to Laravel 8 with the Laravel UI package.