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

replace $request->session() with session() #752

Closed
wants to merge 2 commits into from
Closed

replace $request->session() with session() #752

wants to merge 2 commits into from

Conversation

inmanturbo
Copy link
Contributor

@inmanturbo inmanturbo commented Apr 8, 2021

This PR (refactor) replaces The calls to methods on $request->session() with session() as per @calebporzio 's recommendation in livewire/livewire#936 (comment).

This also eliminates the need for the if ($request->hasSession()) condition in my previous PR, thus bringing the code back one level of indentation.

Tested with the following steps:

laravel new jetstream-demo
cd jetstream-demo
composer require laravel/jetstream
php artisan jetstream:install livewire
npm install && npm run dev
vi phpunit.xml
-        <!-- <server name="DB_CONNECTION" value="sqlite"/> -->
-       <!-- <server name="DB_DATABASE" value=":memory:"/> -->
+       <server name="DB_CONNECTION" value="sqlite"/>
+       <server name="DB_DATABASE" value=":memory:"/>
php artisan test

Also tested in chromium browser against #730


@telkins @Loots-it

#742

#750 (comment)

@taylorotwell
Copy link
Member

Is this actually fixing a problem? It sounds like it's just a preference thing?

@inmanturbo
Copy link
Contributor Author

inmanturbo commented Apr 8, 2021

It sounds like it's just a preference thing?

Yeah I suppose it is more of a preference thing, since we're really not sure if there will be a problem. Livewire was having issues with Request but in this case it may never be a problem for Jetstream, which is working fine as it is.

inmanturbo referenced this pull request Apr 8, 2021
* Check for session before attempting to invalidate

* Fix formatting, missing a space

* $request->hasSession() not $request->session
@peterfox
Copy link
Contributor

Replacing $request->session() with the Session contract fixes the DeleteUserForm test for me. Otherwise it fails due to the request not having a stateful session, most likely because the way Livewire component testing works.

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

Successfully merging this pull request may close these issues.

None yet

3 participants