Eloquent Trick: Group By Raw with Boolean Condition

I know the title sounds unclear, so let me start with an example. What would be your Eloquent query if you have birth_date field in DB an want to show how many of your users are adult 18+ years, and how many are still children? Let's take a look.

Laravel Validation: Specify Attribute Names for Error Messages

Laravel validation system is great, including auto-populating error messages. But what if you want to override the names of the :attribute parameter values? Here's a simple example.

How to Ban/Suspend Users in Laravel Project

Laravel Auth system has a lot of features, but it doesn't include suspending users for some time, like banning some angry forum user for 14 days to calm down. Luckily, it's easy to implement, with Middleware. This article will show you how.

5 Less-Known Features of Spatie Media Library

Spatie Laravel MediaLibrary is one of the most popular Laravel packages, with almost million downloads. But have you read all of its documentation, with all the features? Let's dive in.

Laravel Route Filtering with Regular Expressions

Quick tip of the day. With routing you can specify Route::get('projects/{project_id}', 'ProjectController@show'); but what if you want project_id to be strictly a number?

Laravel Wink Package: WordPress Mini-Alternative for Laravel?

A quick review of Laravel Wink by Mohamed Said. It provides a really pleasant writing experience, but is it good for actual fully-featured blog project? Let's take a look.

Laravel API Errors and Exceptions: How to Return Responses

API-based projects are more and more popular, and they are pretty easy to create in Laravel. But one topic is less talked about - it's error handling for various exceptions. API consumers often complain that they get "Server error" but no valuable messages. So, how to handle API errors gracefully? How to return them in "readable" form?

Route Fallback: If No Other Route is Matched

Laravel 5.5.5 introduced a new feature in routing, called Route::fallback(). Basically, if no route is matched, then fallback function is a way...

EloquentFilter Package Review: Process GET Query Without IF Statements

Quick review of a package called EloquentFilter - it will help you move complicated search logic from controller to separate filter classes, to keep your code cleaner.

Laravel Form with jQuery UI Tabs: Validation Error Redirect to Active Tab

If you have a form separated into a few tabs with jQuery UI Tabs, then default Laravel validation will redirect you back to the first tab, even if the error was on the third tab. How to override it and set the correct tab proactively?





Like our articles?
Check out our Laravel online courses!