Tag: PHP

Null Coalescing Assignment Operator in PHP 7.4

October 27, 2020 By arifpavel
php7.4

Added with PHP 7, the coalesce operator (??) comes in handy when we need to use a ternary operator in conjunction with isset(). It returns the first operand if it exists and is not NULL. Otherwise, it returns the second operand. Here is an example: What this code does is pretty straightforward: it fetches the request parameter and sets a […]

Repository Design pattern in Laravel

October 27, 2020 By arifpavel
Repository Pattern

The Repository Design Pattern There’s an alternative approach to development that abstracts some calls into PHP classes called Repositories. The idea is that we can decouple models from controllers and assign readable names to complicated queries. We’re going to refactor our app to use the Repository Pattern. The first step is to create a file […]

← Prev
Page 1 of 2
Next →