Fetch results based on the existence of the relationship in Laravel Eloquoent
July 12, 2019 — If you want to check if the eloquoent model has certain relationship or not and fetch the results accordingly while querying upon it, you can do this by two approaches in the Laravel Eloquent.
Conditional attributes and relationships in Laravel Resources
July 6, 2019 — When you’re building an Laravel application which uses APIs at some point, it’s no brainer to use Laravel’s resource classes as it provides the transformation layer that sits between your Eloquent models and the JSON responses that are actually returned to your application’s users.
Reusable code snippets using Live Templates in PHPStorm
June 30, 2019 — Let’s just admit this. If you’re a developer who works with PHP and you haven’t heard about PHPStorm, you’re assumed to be living in the rocks. Because PHPStorm is the best PHP IDE exist right now IMHO. The tagline on the homepage of it reads as “The lightening-smart IDE for PHP” and it’s really true. It has got all the features you’d need in order to become a fluent PHP programmer.
Codelobster IDE - A free PHP, HTML, CSS, JavaScript editor (Sponsor)
June 18, 2019 — In this article, we suggest you to get acquainted with the free editor for web languages called Codelobster IDE. It has been there in the software markets for a long time already, and it wins a lot of fans.
Re-using query constraints in Laravel Eloquent - Global vs. Local scopes
June 16, 2019 — Laravel’s Eloquent ORM comes with this unique set of features called “Scopes” which can be used to re-use some of the query constraints onto all the queries of a certain model. This can be useful to minimize the code while writing the query and is an easy way to make sure every query for a given model receives certain constraints.
A closer look at Invokable classes in PHP
June 10, 2019 — In PHP, Invokables refer to any class that may be instantiated without any constructor arguments. In other words, one should be able to create an instance solely be calling new $className()
. To implement an invokable class, one needs to use __invoke() magic method of PHP. Before we understand how invokable exactly works, let’s take a look why invokable classes even exists in PHP.
Logout from every devices except the currently logged in one in Laravel
May 5, 2019 — Every robust web app has this feature where you’re provided with a setting through which you can choose to logout from all the devices you’ve been logged in from previously, except the current one. This is certainly a nice security feature that you can provide to your user without them even asking for it and if your app is built on top of Laravel 5.6, this comes out-of-the-box.
PHP 7.4 will support first-class property type declarations
May 2, 2019 — With the introduction of scalar type declaration and return type declaration in PHP 7.0, the language’s type system got improved at some extent. Although it’s great to have some layer of strictness, it’s still missing the support to declare typed properties. But from PHP 7.4, it seems, it’s going to change because according to this accepted RFC, PHP 7.4 will be getting support for first-class property type declarations.
Laravel Route Model Bindings - Implicit Vs. Explicit Binding
April 29, 2019 — There’s this neat feature in Laravel where you can validate model IDs that have been injected into the route by injecting model instances directly at route level.