Category: Laravel

Writing test is tricky sometimes, one of the feature I like from laravel is is integration with unit test with run smoothly. ok lets pretend we have this code in our Controller We want to test if event App\Events\Member\Created is triggered or not in that Controller so here I wrote the test: You may see this is already documented in laravel docs it self. but I want to highlight on this part: Why we need to specify this? Image, Your Member’s model is using `traits` who requires auth()->user()->id which means this will need to use even-listener of Eloquent for example: so thats answer, by implementing instead of at the top, you will get auth()->user()value exists, otherwise it will benull
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners