Filtering Related Models in Laravel: Using the “whereHas” Method
Learn how to filter query results based on conditions in related models using the Laravel whereHas method.
Learn how to filter query results based on conditions in related models using the Laravel whereHas method.
How to use the Laravel dd() Dump and Die function and dump() to inspect variables and debug your code without setting up a debugger.
How to write cleaner PHP IF statements by using boolean variables directly and the negation operator instead of explicit true and false comparisons.
A PHP code snippet using the date() function to auto-update the copyright year in your website footer so the page always looks current.
A guide to the nine PHP magic constants, including __LINE__, __FILE__, __DIR__, __CLASS__ and __FUNCTION__, and how each one is useful.
How to use enums in PHP to define a fixed set of named constants, access their values, and make your code more readable and maintainable.
How to use try and catch to handle exceptions in PHP, with examples for division by zero and logging errors thrown by third-party API code.
How the PHP increment and decrement operators work, including the surprising behaviour you get when you apply ++ to string values.
How to use PHP type declarations for parameters and return values to write more precise code, catch type errors and reduce DocBlocks.
A roundup of ten PHP tips and tricks from DevChunks, covering dates, redirects, error reporting, the GD library, sending email and more.
More ways to hide PHP usage from visitors: extension-less files via ForceType, MultiViews, and turning off expose_php in php.ini or per file.
How to hide that your site runs on PHP by giving PHP files a different extension and configuring it with an AddType line in .htaccess.