{ Laravel snippets }

Jonathan Reinink

Jonathan Reinink @reinink

Here's a neat trick for soft deleting relationships in @laravelphp. ? When you delete a record, immediately also soft delete any child records. ? Later, when you restore the parent, automatically also restore all child records that were deleted when the parent was deleted. ? https://t.co/YsYKWtu00R

Daily Web Dev

Daily Web Dev @dailywebdev

? Persist request data when redirecting in Laravel with this trick: Chain withInput() onto your redirects and the request values will get persisted to the redirect location - by flashing data to the session under the hood. Includes querystrings and POST data #php #laravel https://t.co/8Vv7QMvfyl

Daily Web Dev

Daily Web Dev @dailywebdev

Being able to hook into different parts of your Laravel app is invaluable. Here are a few ways you can hook into various stages, such as after a route match, before template compilation, after query execution etc. (this would sit inside a service provider ?) #laravel #php https://t.co/yjhhEphcCL

Rasmus C Nielsen

Rasmus C Nielsen @rasmuscnielsen

? When testing API validation responses in #laravelphp you may use the $this->postJson() method rather than $this->post(). This will ensure you get a JSON response rather than the application actually throwing an exception. https://t.co/pDIvSx9yi5

Andrew Schmelyun

Andrew Schmelyun @aschmelyun

Today I learned about Laravel's replicate method, which returns a new instance of a model with the same attributes as the one you're replicating. You can then make changes to the properties of it before saving! https://t.co/oXRwqtgkfL

Chris Fidao

Chris Fidao @fideloper

? TIL Laravel uses transaction for migrations for DB's that supports schema migrations (pgsql, sqlsrv). If you're like me and run a query that cannot be run inside of a transaction (sqlsrv CREATE FULLTEXT CATALOG), you can set the $withinTransaction to false. https://t.co/sAtlzAbLUN