Tracking model attribute changes in Laravel
June 18, 2020 — Sometimes, it’s useful to know if somethig has been changed in the model since it’s been loaded. For instance, you would want to check if the is_published
attribute of the Post
model is set or not before publishing the post further.
Refactor conditions to a method for better readability in PHP
June 16, 2020 — Refactoring is important in programming things. It is a process of restructuring existing computer code—changing the factoring—without changing its external behavior. It makes code more readable, structured and easy to process.
These new string functions are coming in PHP 8
June 13, 2020 — Who would’ve thought that PHP would have to wait till its version 8 or rather 25 years after its inception, to get a truly native and understandable function to check if a string is contained in another string?!
Find the extension of files without extension in Laravel
June 11, 2020 — It’s helpful sometimes when you have a file and it doesn’t have extension attached to it but you want to know the extension of the file regardless.
Non-capturing exception catches in PHP 8
June 10, 2020 — The usual way of handling the exception is by requiring the catch
block to catch the exception (thrown from the try
block) to a variable like so.
Constructor Property Promotion in PHP 8
June 9, 2020 — Wouldn’t it be nice if you don’t have to declare the class property over and over again just to use it across the class? Currently, you’d do it by first declaring it…
Try not to use ad blockers, please!
June 6, 2020 — I used to use Adblockers on my browsers a few years ago because I used to think that Ads are annoying and they probably are. For some people. Like the younger me.
Showing current Git branch for the project in command prompt
June 5, 2020 — It’s always a nice idea to add something to your workflow which can enhance your productivity. Even if it’s as small as showing the current Git branch for your project in command prompt like so.
This nullsafe operator could come in PHP 8
June 4, 2020 — Have you ever wanted a feature where you would only want to call a method or fetch a property on the result of an expression if it is not null
? So, for instance, check the following code.