nexxai

nexxai

Member Since 1 Year Ago

Experience Points 14,100
Experience Level 3

900 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 130
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

22 May
4 weeks ago

nexxai left a reply on PHPUnit Will Not Use :memory: Database

So it turns out that even though I had defined the phpunit.xml file to use ":memory:", at some point I had edited config/sessions.php from 'driver' => env('SESSION_DRIVER', 'database'), to 'driver' => 'database',so it was still trying to use the database for sessions.

Fixed it back to what it should have been, and now my entire test suite has gone down from around 90 minutes to ~5.

Thanks @diegoaurino for your suggestions, but it turns out you can't fix stupid.

nexxai left a reply on PHPUnit Will Not Use :memory: Database

@diegoaurino Thanks for that suggestion, but I actually already tried that

Configuring my phpunit.xml to use:

  `<env name="DB_CONNECTION" value="testing"/>`

as well as:

 ` <env name="DB_CONNECTION" value="sqlite"/>`
  ` <env name="DB_DATABASE" value=":memory:"/>`
21 May
4 weeks ago

nexxai left a reply on PHPUnit Will Not Use :memory: Database

For posterity's sake, I compared my phpunit.xml with one from a new, blank Laravel installation and noticed that the entries within have gone from <env to <server so I updated those and now it's still failing but at least it's a console error now, and not within some HTML:

➜  exampleSite git:(issue-collections-edit-not-showing-correct-format) ✗ phpunit --filter a_user_can_reorder_a_Examples_characters_by_importance
PHPUnit 7.5.9 by Sebastian Bergmann and contributors.

E                                                                   1 / 1 (100%)

Time: 231 ms, Memory: 20.00 MB

There was 1 error:

1) Tests\Feature\ExampleTest::a_user_can_reorder_a_Examples_characters_by_importance
Illuminate\Database\QueryException: SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = ? and table_name = laralum_permissions and table_type = 'BASE TABLE')

/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Connection.php:624
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Connection.php:333
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Schema/MySqlBuilder.php:18
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:237
/Users/nexxai/code/exampleSite/vendor/laralum/permissions/src/PermissionsChecker.php:43
/Users/nexxai/code/exampleSite/vendor/laralum/laralum/src/LaralumServiceProvider.php:59
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:90
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:34
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Container/Container.php:576
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:817
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:800
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:801
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/BootProviders.php:17
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:210
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:311
/Users/nexxai/code/exampleSite/tests/CreatesApplication.php:19
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:92
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:69
/Users/nexxai/code/exampleSite/tests/Feature/ExampleTest.php:15
/Users/nexxai/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:207
/Users/nexxai/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:163

Caused by
Doctrine\DBAL\Driver\PDOException: SQLSTATE[HY000] [2002] Connection refused

/Users/nexxai/code/exampleSite/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:31
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:67
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:46
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php:24
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php:182
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Connection.php:918
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Connection.php:943
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Connection.php:399
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Connection.php:325
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Connection.php:657
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Connection.php:624
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Connection.php:333
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Schema/MySqlBuilder.php:18
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:237
/Users/nexxai/code/exampleSite/vendor/laralum/permissions/src/PermissionsChecker.php:43
/Users/nexxai/code/exampleSite/vendor/laralum/laralum/src/LaralumServiceProvider.php:59
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:90
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:34
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Container/Container.php:576
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:817
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:800
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:801
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/BootProviders.php:17
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:210
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:311
/Users/nexxai/code/exampleSite/tests/CreatesApplication.php:19
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:92
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:69
/Users/nexxai/code/exampleSite/tests/Feature/ExampleTest.php:15
/Users/nexxai/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:207
/Users/nexxai/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:163

Caused by
PDOException: SQLSTATE[HY000] [2002] Connection refused

/Users/nexxai/code/exampleSite/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:27
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:67
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:46
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php:24
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php:182
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Connection.php:918
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Connection.php:943
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Connection.php:399
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Connection.php:325
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Connection.php:657
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Connection.php:624
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Connection.php:333
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Database/Schema/MySqlBuilder.php:18
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:237
/Users/nexxai/code/exampleSite/vendor/laralum/permissions/src/PermissionsChecker.php:43
/Users/nexxai/code/exampleSite/vendor/laralum/laralum/src/LaralumServiceProvider.php:59
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:90
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:34
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Container/Container.php:576
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:817
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:800
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:801
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/BootProviders.php:17
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:210
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:311
/Users/nexxai/code/exampleSite/tests/CreatesApplication.php:19
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:92
/Users/nexxai/code/exampleSite/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:69
/Users/nexxai/code/exampleSite/tests/Feature/ExampleTest.php:15
/Users/nexxai/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:207
/Users/nexxai/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:163

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
➜  exampleSite git:(issue-collections-edit-not-showing-correct-format) ✗ 

nexxai started a new conversation PHPUnit Will Not Use :memory: Database

Ok so I'm definitely taking crazy pills, I just can't figure out which ones.

No matter what I do, I cannot get PHPUnit to use the in-memory database. I've tried:

Setting my .env to this (just to ensure it wasn't using the real database connection in the background):

DB_CONNECTION=sqlite
DB_DATABASE=":memory:"

and also:

DB_CONNECTION=testing

while having database.php show:

        'testing' => [
            'driver' => 'sqlite',
            'database' => ':memory:',
            'prefix' => '',
        ],

Configuring my phpunit.xml to use:

        <env name="DB_CONNECTION" value="testing"/>

as well as:

        <env name="DB_CONNECTION" value="sqlite"/>
        <env name="DB_DATABASE" value=":memory:"/>

This is an example error, which is weird because it's showing the Connection.php error inside the HTML of the page it's testing:

1) Tests\Feature\ExampleTest::a_user_can_reorder_a_Examples_characters_by_importance
Failed asserting that Failed asserting that '<!DOCTYPE html><!--


Illuminate\Database\QueryException: SQLSTATE[HY000] [2002] Connection refused (SQL: select * from `sessions` where `id` = y6wLaM4CgTSQjVjpHzzcxOISLhZTfoLpaCr9mEiN limit 1) in file /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Database/Connection.php on line 664
Stack trace:
  1. Illuminate\Database\QueryException-&gt;() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
  2. Doctrine\DBAL\Driver\PDOException-&gt;() /Users/nexxai/code/examplesite/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:31
  3. PDOException-&gt;() /Users/nexxai/code/examplesite/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:27
  4. PDO-&gt;__construct() /Users/nexxai/code/examplesite/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:27
  5. Doctrine\DBAL\Driver\PDOConnection-&gt;__construct() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:67
  6. Illuminate\Database\Connectors\Connector-&gt;createPdoConnection() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:46
  7. Illuminate\Database\Connectors\Connector-&gt;createConnection() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php:24
  8. Illuminate\Database\Connectors\MySqlConnector-&gt;connect() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php:182
  9. Illuminate\Database\Connectors\ConnectionFactory-&gt;Illuminate\Database\Connectors\{closure}() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Database/Connection.php:918
 10. call_user_func() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Database/Connection.php:918
 11. Illuminate\Database\Connection-&gt;getPdo() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Database/Connection.php:943
 12. Illuminate\Database\Connection-&gt;getReadPdo() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Database/Connection.php:399
 13. Illuminate\Database\Connection-&gt;getPdoForSelect() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Database/Connection.php:325
 14. Illuminate\Database\Connection-&gt;Illuminate\Database\{closure}() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Database/Connection.php:657
 15. Illuminate\Database\Connection-&gt;runQueryCallback() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Database/Connection.php:624
 16. Illuminate\Database\Connection-&gt;run() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Database/Connection.php:333
 17. Illuminate\Database\Connection-&gt;select() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2124
 18. Illuminate\Database\Query\Builder-&gt;runSelect() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2112
 19. Illuminate\Database\Query\Builder-&gt;Illuminate\Database\Query\{closure}() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2598
 20. Illuminate\Database\Query\Builder-&gt;onceWithColumns() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2113
 21. Illuminate\Database\Query\Builder-&gt;get() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php:77
 22. Illuminate\Database\Query\Builder-&gt;first() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2087
 23. Illuminate\Database\Query\Builder-&gt;find() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Session/DatabaseSessionHandler.php:91
 24. Illuminate\Session\DatabaseSessionHandler-&gt;read() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Session/Store.php:97
 25. Illuminate\Session\Store-&gt;readFromHandler() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Session/Store.php:87
 26. Illuminate\Session\Store-&gt;loadSession() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Session/Store.php:71
 27. Illuminate\Session\Store-&gt;start() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php:81
 28. Illuminate\Session\Middleware\StartSession-&gt;Illuminate\Session\Middleware\{closure}() /Users/nexxai/.composer/vendor/illuminate/support/helpers.php:1027
 29. tap() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php:82
 30. Illuminate\Session\Middleware\StartSession-&gt;startSession() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php:51
 31. Illuminate\Session\Middleware\StartSession-&gt;handle() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
 32. Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 33. Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php:37
 34. Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse-&gt;handle() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
 35. Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 36. Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}() /Users/nexxai/code/examplesite/app/Http/Middleware/UpdateLastSeen.php:19
 37. App\Http\Middleware\UpdateLastSeen-&gt;handle() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
 38. Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 39. Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php:66
 40. Illuminate\Cookie\Middleware\EncryptCookies-&gt;handle() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
 41. Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 42. Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:104
 43. Illuminate\Pipeline\Pipeline-&gt;then() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Routing/Router.php:682
 44. Illuminate\Routing\Router-&gt;runRouteWithinStack() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Routing/Router.php:657
 45. Illuminate\Routing\Router-&gt;runRoute() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Routing/Router.php:623
 46. Illuminate\Routing\Router-&gt;dispatchToRoute() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Routing/Router.php:612
 47. Illuminate\Routing\Router-&gt;dispatch() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:176
 48. Illuminate\Foundation\Http\Kernel-&gt;Illuminate\Foundation\Http\{closure}() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:30
 49. Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}() /Users/nexxai/code/examplesite/vendor/beyondcode/laravel-query-detector/src/QueryDetectorMiddleware.php:33
 50. BeyondCode\QueryDetector\QueryDetectorMiddleware-&gt;handle() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
 51. Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 52. Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}() /Users/nexxai/code/examplesite/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php:58
 53. Barryvdh\Debugbar\Middleware\InjectDebugbar-&gt;handle() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
 54. Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 55. Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}() /Users/nexxai/code/examplesite/vendor/fideloper/proxy/src/TrustProxies.php:57
 56. Fideloper\Proxy\TrustProxies-&gt;handle() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
 57. Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 58. Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:21
 59. Illuminate\Foundation\Http\Middleware\TransformsRequest-&gt;handle() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
 60. Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 61. Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:21
 62. Illuminate\Foundation\Http\Middleware\TransformsRequest-&gt;handle() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
 63. Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 64. Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php:27
 65. Illuminate\Foundation\Http\Middleware\ValidatePostSize-&gt;handle() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
 66. Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 67. Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php:62
 68. Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode-&gt;handle() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:163
 69. Illuminate\Pipeline\Pipeline-&gt;Illuminate\Pipeline\{closure}() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53
 70. Illuminate\Routing\Pipeline-&gt;Illuminate\Routing\{closure}() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:104
 71. Illuminate\Pipeline\Pipeline-&gt;then() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:151
 72. Illuminate\Foundation\Http\Kernel-&gt;sendRequestThroughRouter() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:116
 73. Illuminate\Foundation\Http\Kernel-&gt;handle() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:347
 74. Illuminate\Foundation\Testing\TestCase-&gt;call() /Users/nexxai/code/examplesite/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:170
 75. Illuminate\Foundation\Testing\TestCase-&gt;get() /Users/nexxai/code/examplesite/tests/Feature/ExampleTest.php:145
 76. Tests\Feature\ExampleTest-&gt;a_user_can_reorder_a_Examples_characters_by_importance() /Users/nexxai/code/examplesite/vendor/phpunit/phpunit/src/Framework/TestCase.php:1153
 77. PHPUnit\Framework\TestCase-&gt;runTest() /Users/nexxai/code/examplesite/vendor/phpunit/phpunit/src/Framework/TestCase.php:842
 78. PHPUnit\Framework\TestCase-&gt;runBare() /Users/nexxai/code/examplesite/vendor/phpunit/phpunit/src/Framework/TestResult.php:687
 79. PHPUnit\Framework\TestResult-&gt;run() /Users/nexxai/code/examplesite/vendor/phpunit/phpunit/src/Framework/TestCase.php:796
 80. PHPUnit\Framework\TestCase-&gt;run() /Users/nexxai/code/examplesite/vendor/phpunit/phpunit/src/Framework/TestSuite.php:746
 81. PHPUnit\Framework\TestSuite-&gt;run() /Users/nexxai/code/examplesite/vendor/phpunit/phpunit/src/Framework/TestSuite.php:746
 82. PHPUnit\Framework\TestSuite-&gt;run() /Users/nexxai/code/examplesite/vendor/phpunit/phpunit/src/Framework/TestSuite.php:746
 83. PHPUnit\Framework\TestSuite-&gt;run() /Users/nexxai/code/examplesite/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:641
 84. PHPUnit\TextUI\TestRunner-&gt;doRun() /Users/nexxai/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:207
 85. PHPUnit\TextUI\Command-&gt;run() /Users/nexxai/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:163
 86. PHPUnit\TextUI\Command-&gt;main() /Users/nexxai/.composer/vendor/phpunit/phpunit/phpunit:61











--><html>
  <head>
    <meta charset="utf-8">
    <meta name="robots" content="noindex,nofollow"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
    <title>Whoops! There was an error.</title>

It's almost as if PHPUnit is ignoring the phpunit.xml file altogether.

Is there a way that I can test (even something stupid like echoing out a "caught" string) if it's even seeing the phpunit.xml file, or if there's something obvious that I've done wrong with it?

<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         bootstrap="vendor/autoload.php"
         colors="true"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false">
    <testsuites>
        <testsuite name="Feature">
            <directory suffix="Test.php">./tests/Feature</directory>
        </testsuite>

        <testsuite name="Unit">
            <directory suffix="Test.php">./tests/Unit</directory>
        </testsuite>
    </testsuites>
    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">./app</directory>
        </whitelist>
    </filter>
    <php>
        <env name="APP_ENV" value="testing"/>
        <env name="DB_CONNECTION" value="testing"/>
        <env name="CACHE_DRIVER" value="array"/>
        <env name="SESSION_DRIVER" value="array"/>
        <env name="QUEUE_DRIVER" value="sync"/>
    </php>
</phpunit>
12 Mar
3 months ago

nexxai left a reply on Eloquent Query For Great-grandchildren?

@JLRDW - Using his example, each employee's benefits date would be different, based on when they started with the company and/or when their probationary period concludes, for example.

nexxai left a reply on Token Mismatch Exception

If you view the source of the page, what is being returned as the <input type="hidden" name="_token" ... field? If you refresh the page, is the token value changing?

nexxai left a reply on How To Find Last Row From Second Table, Along With Its First Table Row

Why not do this:

public function index()
    {
       $volumes = journal::with('volume')->first();
        return view('welcome',compact('volumes '));
    }


use App\volume;

class journal extends Model
{
   function volume()
     {
          return $this->hasMany(volume::class, 'journal_id')
        ->orderByDesc('id');
     }
}

Replace ->get() with ->first(), and then orderByDesc() so that it fetches them in reverse order

nexxai left a reply on Token Mismatch Exception

You will need to include the CSRF token as part of the sign-in process. If the sign-in page is part of the Laravel app, just add

@csrf

Within your tags and it will supply that for you.

Alternatively, you can look into disabling CSRF for that page specifically, however due to the protection it provides your users, I would not recommend that.

nexxai started a new conversation Use Forge To Deploy From Azure DevOps Git Repo

I have a git repo hosted in our company's Azure DevOps tenant and I'm having a heck of a time getting Forge to see it as a proper repo.

Has anyone had success doing this, and if so, what did you provide for the repository information within Forge?

19 Oct
8 months ago

nexxai left a reply on Sorting By Appended Attribute

You are the MAN! Thank you so much, that works perfectly!

nexxai left a reply on Sorting By Appended Attribute

@wilk_randall So I just tried doing this:

    public function getTotalScoreAttribute()
    {
        if ($this->total_score) {
            return $this->total_score;
        }

        return $this->countTotalVotes();
    }

but it failed with this error:

Undefined property: App\Feature::$total_score 

I'm guessing because of the circular logic (to get the total_score, we first must get the total score....) I also tried doing this:

    public function getTotalScoreAttribute()
    {
        return $this->countTotalVotes();
    }

    public function getScoreAttribute()
    {
        if ($this->total_score) {
            return $this->total_score;
        }

        return $this->countTotalVotes();
    }

but still when I call $feature->score, it's still doubling the DB queries.

nexxai started a new conversation Sorting By Appended Attribute

Ok, so let's say I have a model like this:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use App\Helpers\Helper;

class Feature extends Model
{

    protected $appends = [
         'total_score'
    ];

    public function getTotalScoreAttribute()
    {
        return $this->countTotalVotes();  // this method is inside the Helpers\Helper
    }
}

and this controller method:

    public function index()
    {
        $features = Feature::all();

        $features->sortByDesc('total_score');

        return view('features.index')->withFeatures($features);
    }

Why does the total_score have to be computed twice, once during the initial get() but then again when I want to sort it by the score? When I return the collection before sorting, the total_score property/attribute is there, but it's like the ->sortByDesc() says "screw this, I'm doing it again myself". Am I doing something wrong, or is what I'm trying to do impossible?

11 Sep
9 months ago

nexxai left a reply on Very Slow PHPUnit Tests Using PHP7.2 Or PHP7.1.

For those who are running PHP 7.2, I had to do this to remove xdebug:

pecl uninstall xdebug

Then I had to edit my php.ini file and remove the two xdebug.so lines. Once I did that, the speed of my test suite went from ~25 seconds down to 8.

nexxai left a reply on Testing Validation Of An Input Array

@qiutuleng Thank you so much! That works perfectly!

10 Sep
9 months ago

nexxai started a new conversation Testing Validation Of An Input Array

Let's say I have this HTML:

<input type="text" id="name" name="name[]" class="form-control" value="" required="">
<input type="text" id="name" name="name[]" class="form-control" value="" required="">
<input type="text" id="name" name="name[]" class="form-control" value="" required="">
<input type="text" id="name" name="name[]" class="form-control" value="" required="">

And in my request validator, I have this:

public function rules()
{
    return [
        'name.*' => 'required|string'
    ];
}

The test that I'm trying to write to ensure that the validation is working is:

    $person = make('App\Person', ['name' => null]);
    $this->post('/person', $person->toArray())
        ->assertSessionHasErrors('name');

The validation actually works and makes sure that each entry has data in the field, but I don't understand how I'd test that with assertSessionHasErrors, because it looks for the name of the variable, but in this case it's an array ("name[]") rather than a single variable (e.g. "name").

I've tried variations on the assertSessionHasErrors() like:

        ->assertSessionHasErrors('name[]');

        ->assertSessionHasErrors('name.*');

But nothing I try will make it work.

Does anyone know what I'm missing here?

01 Sep
9 months ago

nexxai left a reply on Unknown Database ':memory:'

So it turns out I'm an idiot.

I had both DB_CONNECTION as well as DB_DRIVER and DB_DATABASE defined in the phpunit.xml; I got rid of _DRIVER and _DATABASE leaving only _CONNECTION and it works now.

nexxai left a reply on Unknown Database ':memory:'

If I try running it as "phpunit -c phpunit.xml", it just gives me the same errors again:

➜  project git:(master) ✗ phpunit -c phpunit.xml 
PHPUnit 7.3.3 by Sebastian Bergmann and contributors.

E                                                                   1 / 1 (100%)

Time: 804 ms, Memory: 42.69MB

There was 1 error:

1) Tests\Feature\ProductionTest::a_user_can_browse_productions
Illuminate\Database\QueryException: SQLSTATE[HY000] [1049] Unknown database ':memory:' (SQL: select * from `sessions` where `id` = Oqjne2uDE1BOEwWovGdo8pkqO45Pqzgb9Ijspuxq limit 1)

/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:624
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:333
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1963
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1951
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2435
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1952
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php:77
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1926
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Session/DatabaseSessionHandler.php:91
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Session/DatabaseSessionHandler.php:128
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Session/Store.php:129
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php:87
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:218
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:189
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:352
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:168
/Users/nexxai/code/project/tests/Feature/ProductionTest.php:15

Caused by
Doctrine\DBAL\Driver\PDOException: SQLSTATE[HY000] [1049] Unknown database ':memory:'

/Users/nexxai/code/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:50
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:65
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:44
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php:24
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php:182
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:915
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:940
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:399
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:325
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:657
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:624
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:333
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1963
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1951
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2435
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1952
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php:77
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1926
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Session/DatabaseSessionHandler.php:91
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Session/DatabaseSessionHandler.php:128
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Session/Store.php:129
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php:87
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:218
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:189
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:352
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:168
/Users/nexxai/code/project/tests/Feature/ProductionTest.php:15

Caused by
PDOException: SQLSTATE[HY000] [1049] Unknown database ':memory:'

/Users/nexxai/code/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:46
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:65
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:44
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php:24
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php:182
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:915
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:940
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:399
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:325
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:657
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:624
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:333
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1963
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1951
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2435
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1952
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php:77
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1926
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Session/DatabaseSessionHandler.php:91
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Session/DatabaseSessionHandler.php:128
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Session/Store.php:129
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php:87
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:218
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:189
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:352
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:168
/Users/nexxai/code/project/tests/Feature/ProductionTest.php:15

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.

nexxai left a reply on Unknown Database ':memory:'

No dice

➜  project git:(master) ✗ ./vendor/bin/phpunit phpunit.xml
./tests/Feature
    <testsuite name="Unit">
        <directory suffix="Test.php">./tests/Unit</directory>
    </testsuite>
</testsuites>
<filter>
    <whitelist processUncoveredFilesFromWhitelist="true">
        <directory suffix=".php">./app</directory>
    </whitelist>
</filter>
<php>
    <env name="APP_ENV" value="testing"/>
    <env name="DB_CONNECTION" value="sqlite" force="true"/>
    <env name="DB_DATABASE" value=":memory:" force="true"/>
    <env name="DB_DRIVER" value="sqlite" force="true"/>
    <env name="CACHE_DRIVER" value="array"/>
    <env name="SESSION_DRIVER" value="array"/>
    <env name="QUEUE_DRIVER" value="sync"/>
</php>

PHP Fatal error: Uncaught PHPUnit\Runner\Exception: Class 'phpunit' could not be found in '/Users/nexxai/code/project/phpunit.xml'. in /Users/nexxai/code/project/vendor/phpunit/phpunit/src/Runner/StandardTestSuiteLoader.php:102 Stack trace: #0 /Users/nexxai/code/project/vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php(130): PHPUnit\Runner\StandardTestSuiteLoader->load('phpunit', '/Users/nexxai/c...') #1 /Users/nexxai/code/project/vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php(73): PHPUnit\Runner\BaseTestRunner->loadSuiteClass('phpunit', '/Users/nexxai/c...') #2 /Users/nexxai/code/project/vendor/phpunit/phpunit/src/TextUI/Command.php(169): PHPUnit\Runner\BaseTestRunner->getTest('phpunit', '/Users/nexxai/c...', Array) #3 /Users/nexxai/code/project/vendor/phpunit/phpunit/src/TextUI/Command.php(148): PHPUnit\TextUI\Command->run(Array, true) #4 /Users/nexxai/code/project/vendor/phpunit/phpunit/phpunit(53): PHPUnit\TextUI\Command::main() #5 {main} thrown in /Users/nexxai/code/project/vendor/phpunit/phpunit/src/Runner/StandardTestSuiteLoader.php on line 102

Fatal error: Uncaught PHPUnit\Runner\Exception: Class 'phpunit' could not be found in '/Users/nexxai/code/project/phpunit.xml'. in /Users/nexxai/code/project/vendor/phpunit/phpunit/src/Runner/StandardTestSuiteLoader.php on line 102

PHPUnit\Runner\Exception: Class 'phpunit' could not be found in '/Users/nexxai/code/project/phpunit.xml'. in /Users/nexxai/code/project/vendor/phpunit/phpunit/src/Runner/StandardTestSuiteLoader.php on line 102

Call Stack: 0.0028 394664 1. {main}() /Users/nexxai/code/project/vendor/phpunit/phpunit/phpunit:0 0.0194 2461432 2. PHPUnit\TextUI\Command::main() /Users/nexxai/code/project/vendor/phpunit/phpunit/phpunit:53 0.0194 2461544 3. PHPUnit\TextUI\Command->run() /Users/nexxai/code/project/vendor/phpunit/phpunit/src/TextUI/Command.php:148 0.0269 3017368 4. PHPUnit\TextUI\TestRunner->getTest() /Users/nexxai/code/project/vendor/phpunit/phpunit/src/TextUI/Command.php:169 0.0269 3017368 5. PHPUnit\TextUI\TestRunner->loadSuiteClass() /Users/nexxai/code/project/vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php:73 0.0274 3034408 6. PHPUnit\Runner\StandardTestSuiteLoader->load() /Users/nexxai/code/project/vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php:130

nexxai left a reply on Unknown Database ':memory:'

And yes, sqlite is installed on my machine:

➜  project git:(master) ✗ brew install sqlite
Warning: sqlite 3.24.0 is already installed and up-to-date
To reinstall 3.24.0, run `brew reinstall sqlite`

nexxai left a reply on Unknown Database ':memory:'

Ok, something I snipped might actually be important:

Caused by
PDOException: SQLSTATE[HY000] [1049] Unknown database ':memory:'

/Users/nexxai/code/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:46
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:65
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:44
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php:24
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php:182
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:915
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:940
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:399
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:325
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:657
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:624
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Connection.php:333
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1963
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1951
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2435
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1952
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php:77
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:1926
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Session/DatabaseSessionHandler.php:91
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Session/DatabaseSessionHandler.php:128
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Session/Store.php:129
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php:87
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:218
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:189
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:352
/Users/nexxai/code/project/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:168
/Users/nexxai/code/project/tests/Feature/ProductionTest.php:15

It looks like it's trying to use MySQL even though I've specified sqlite as the driver. I've tried doing a

php artisan config:clear

but it doesn't seem to make a difference

nexxai left a reply on Ajax Request Throws Methodnotallowed Exception

What some people might do to make the route more "REST-friendly" is make your vote route:

Route::post('/article/{article}/vote', '[email protected]');

nexxai left a reply on Ajax Request Throws Methodnotallowed Exception

Yes, but Laravel doesn't know if "vote' is referring to an article (as in your first route) or a hardcoded path (your second route). Since it reads the file from top to bottom, just put the more specific route above the less specific one and it'll work like you expect.

nexxai left a reply on Ajax Request Throws Methodnotallowed Exception

Right, so since you have

Route::get('/article/{article}', '[email protected]');

before

Route::post('/article/vote/{article}', '[email protected]');

in your routes/web.php file, it's matching on the first one instead of the second. Put the post route above the get route and it should start working.

nexxai started a new conversation Unknown Database ':memory:'

Am I missing something here? I've got my phpunit.xml set up correctly (I think):

<env name="APP_ENV" value="testing"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/> 

But no matter what I do, I keep getting this error:

PHPUnit 7.2.7 by Sebastian Bergmann and contributors.

E                                                                   1 / 1 (100%)

Time: 874 ms, Memory: 42.66MB

There was 1 error:

1) Tests\Feature\ProductionTest::a_user_can_browse_productions
Illuminate\Database\QueryException: SQLSTATE[HY000] [1049] Unknown database ':memory:' (SQL: select * from `sessions` where `id` = zX4xORwbal5OzBZv7ZfuvAhHamcHZkAFTHUgxjn5 limit 1)


[snip...]

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.

I feel like I'm taking crazy pills.

19 Aug
10 months ago

nexxai left a reply on Best Way To Bisect Two Large Collections

This is along the lines of what I ended up doing - I built each dropdown as a search field that queries the DB via an API endpoint, basically like an auto-complete.

18 Aug
10 months ago

nexxai left a reply on Best Way To Bisect Two Large Collections

@Snapey @brightstormhq So what's happening prior to that is the user is filling out a form on the previous page that effectively a wide open text box that we then use a bunch of regex to parse specific items out of, but since we know that regexing user input is imperfect, what we want to do is provide the list of items we think we parsed out correctly, but then give all of the available items we know of below it, in case we messed up.

The more I think about it, the more I think I should have some kind of auto-completing text field that queries the DB for the available entries based on what's been typed rather than generating the list possibly as many as 20 or more times on a single page.

Thanks guys, I appreciate your input.

nexxai started a new conversation Best Way To Bisect Two Large Collections

I have a very large collection (several thousand items), and given a much smaller collection of similar items (let's say 5-20 of them), I need to find and select them for further processing.

Currently I do it like this:

        // This is the list of 5-20
        $new_items = Item::where('prepared', 0)
            ->get();

        // Get existing items..
        $all_items = Item::all();

        // and figure out which items haven't been shown above
        // to create a bisected/diffed collection of just them
        $remaining_items = $all_items->diffAssoc($new_items);

In the view I've got:

                    @foreach ($stuffs as $stuff)
                    <div class="row">
                        <div class="form-group col-md-8">
                            <label for="name[{{$stuff->id}}]">{{$stuff->name}}</label>

                            <select class="dropdown-autocomplete-menu form-control" id="name[{{$stuff->id}}]" name="name[{{$stuff->id}}]">
                                <option disabled selected>
                                    Select the performer who played this role or choose 'Not listed'
                                </option>

                                <optgroup label="Detected items">
                                    @foreach ($remaining_items as $item)
                                    <option value="{{ $item->id }}">
                                        {{ $item->full_name }}
                                    </option>
                                    @endforeach
                                </optgroup>

                                <optgroup label="Other items">
                                    @foreach ($all_items as $item)
                                    <option value="{{ $item->id }}">
                                        {{ $item->full_name }}
                                    </option>
                                    @endforeach
                                </optgroup>

                                <option value="-999">Not listed</option>
                            </select>
                        </div>
                    @endforeach 

But if I understand it correctly (and I'm still very much a novice), this is the N+1 problem (or possibly much worse). Is there a way to more efficiently generate the view so that it doesn't take so long to render the page?

06 Jul
11 months ago

nexxai left a reply on Question About Caching And Best Practices

Ok, so after each create/update/delete event, you update both the individual model in the cache, but also the collection of models in the cache using cache keys? I just want to make sure I'm understanding correctly.

nexxai started a new conversation Question About Caching And Best Practices

So I've finally put on my big boy pants and have decided to look into caching as one method to help increase performance of my application, but I'm having a hard time wrapping my head around the best way to go about it.

I know that physically it's simple: enable the Redis cache driver, add

use Illuminate\Support\Facades\Cache;

to the top of my controller and presto finito, we're caching. What I don't understand is how and when I should be caching.

My app is something vaguely similar to a wiki of sorts, and so there's no schedule in which data can be assumed to be static for. With that being the case, I know that I can't just do:

$sprockets = Cache::remember('sprockets', 60, function () {
    return Sprocket::all();
});

because what if someone updates a Data object within those 60 seconds; they're gonna be fed old data (right?). And because the site is very much based on user contributions, I don't want someone to make an update only to go back to the main index view and not see their changes.

So I feel like I'm missing a step, like one where after every update, not only is the database table updated, but also several keys in the cache (e.g. not only the individual model record, but also the overall index). And if that's the case, can someone point me in the direction of some information about how and when it's best to do that?

I feel like I've got this massive hole in my understanding here but I want - nay, need - to figure it out, if for no other reason than my own sanity.

Thanks

02 Apr
1 year ago

nexxai left a reply on How Do I Properly Sort This Distant Relationship

For future searchers, this is what I ended up doing:

    $performer = Performer::where('id', $id)
        ->with('castmember.character', 'castmember.performance.tour.production')
        ->with(['castmember' => function ($query) {
            $query->join('performances', 'castmembers.performance_id', '=', 'performances.id')
                ->select('performances.*', 'castmembers.*')
                ->orderBy('date', 'asc');
        }])
        ->first();
01 Apr
1 year ago

nexxai started a new conversation How Do I Properly Sort This Distant Relationship

Here's the code:

    $performer = Performer::with(
        'castmember.performance.tour.production',
        'castmember.character'
    )
        ->where('id', $id)
        ->firstOrFail();

Here are the relationships:

Performer:

public function castmember()
{
    return $this->hasMany(\App\Castmember::class);
}

Castmember:

public function performance()
{
    return $this->belongsTo(\App\Performance::class);
}

and I'm trying to sort by the "date" property on the Performance model so that we can display a chronological list of every performance a performer has been a part of.

The Castmember model is something like a pivot table except each instance tracks 3 things: the performer we're talking about, the performance they performed in, and the character they played.

What I've tried:

  • Various joins
  • Query scopes
  • Nested query constraints
  • probably some other stuff I'm forgetting here

I feel like this can't be the first time someone's tried to do this, but I'm at a loss here; what am I missing?

25 Mar
1 year ago

nexxai left a reply on Charts With Filters

Yeah, you'd want to build that filtering into your model query so that you're not returning every result and then filtering after the fact, since depending on how much data is in the original query, you could be looking at a TON of wasted resources (e.g. performing a query that returns 10,000 results only to filter out 100 after the fact to display; instead write the original query so that it only retrieves those 100 results the first time).

nexxai started a new conversation Can You Remove A Foreign Key Reference Without Dropping The Column Entirely?

Say I used these lines in a migration:

$table->integer('dog_id')->unsigned();
$table->foreign('dog_id')->references('id')->on('dogs');

Now say later in development, I realized that I should have generalized better and so what I want to do is rename the "dogs" table to "pets". I rename the table to "pets" and rename columns to "pet_id" and that all works, but the foreign key relationship is still pointing to the "dogs" table. Do I just do:

$table->dropForeign('dog_id');

and call it a day? If that actually drops all the data in that column then that's bad. Or is there something else I need to do too?

Thanks

17 Mar
1 year ago

nexxai left a reply on Using Flysystem, How Do I Get Uploaded Files' Storage::url To Return The Correct CNAME

@shez1983 Darn, I was afraid that was going to be the case.

Thanks

nexxai left a reply on Large List Of Collection Items (names) - Is There A Way To Skip To A Letter?

@jlrdw I'm not sure what you mean - I meant that I tested both with and without query parameters, just to rule out whether or not they were causing the problem.

Can you show me the examples you're referring to so that I can see if there's anything useful in them?

Thanks

nexxai left a reply on Large List Of Collection Items (names) - Is There A Way To Skip To A Letter?

@Cronix So I tried that but now I'm getting:

Call to undefined method Illuminate\Database\Query\Builder::links()

even on the original request (with no query parameters). Is that because the query has been split up and it's gone from a collection to a query builder?

nexxai started a new conversation Large List Of Collection Items (names) - Is There A Way To Skip To A Letter?

We have a large database of names, and we'd like to allow our users to jump to a particular letter in a view. We currently just use basic pagination but that's becoming untenable as the list of names is constantly growing, and by a lot.

Is there a way where we can keep pagination (if not, that's OK), but have the ability for our users to skip to a particular letter in the list?

Current lookup code:

    $people = Person::where('approved', 1)
        ->orderBy('first_name')
        ->paginate(30);

Current (simplified) display code:

@foreach ($people as $person)

    <tr><td>{{ $person->name }}</td></tr>

@endforeach

$people->links()

I think I could probably do a groupBy, but the unintended side effect of using a groupBy is that it would either be one gigantic page split up into letter-specific names, or having a single page for each letter which will still look unbalanced if you have letters with a ton of names vs. letters with few or no names.

Thoughts?

nexxai started a new conversation Using Flysystem, How Do I Get Uploaded Files' Storage::url To Return The Correct CNAME

I've set up the DNS CNAME just fine and it's working, but when I upload files (working fine), the url it returns is:

    https://s3.amazonaws.com/cname.domain.com/file.ext

rather than

    http://cname.domain.com/file.ext

I'm uploading the files like this:

    $storagelocation = Storage::put('uploads', request()->file('upload'));
    $url = Storage::url($storagelocation);

In my config/filesystems.php, I've tried adding

        'cname' => 'cname.domain.com',

        'cname' => 'https://cname.domain.com',

        'base_url' => 'https://cname.domain.com',

but nothing seems to work. Does anyone have any experience with this?

03 Jan
1 year ago

nexxai left a reply on Very Basic Question(s?) About Application Architecture

That was super helpful, thanks Bobby! I think my brain was just expecting(?) there to be a Laravel-specific way of doing it (like php artisan make:interface or something) but since I couldn't find anything in the documentation, I was worried I was just missing something.

Thank you again!

nexxai left a reply on Validate Encrypted

You should look over ParagonIE's document about building searchable, encrypted databases: https://paragonie.com/blog/2017/05/building-searchable-encrypted-databases-with-php-and-sql

02 Jan
1 year ago

nexxai started a new conversation Very Basic Question(s?) About Application Architecture

This is more of a theory question than a "how do I..." but here goes:

I am relatively new to Laravel, PHP, and programming in general. I've got what I think is a decent grasp of the basic concepts of the MVC architecture, but beyond that, things start to get a bit hazy.

I've gone through and watched the SOLID Principles video series, as well as the OOP video series, and in them Jeffrey creates interfaces and abstract classes as examples, but in a general PHP (not Laravel-specific) format.

What I don't "get" is: if I want to create an interface, is there a Laravel-specific way of doing that? Or do I just write "normal" PHP and add the files as necessary? And if I just write the "normal" PHP stuff, do I have to manually add the files to my composer.json so that they're picked up in the autoloader? Or if I put them in the "app/" location, will they be automatically detected?

I feel like I have a good grasp on the absolute basics, but then this massive hole of knowledge of anything that doesn't fit in a controller or model.

I apologize if these sound like stupid questions, but I don't know what I don't know and so I don't even know what I should be Googling for to try and figure it out.

Thank you very much for trying to help me understand things better