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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners