Laravel Tip — Always Set Table Name Explicitly

Updated: 17th October 2025
Tags: php laravel

When defining Eloquent models, it’s a good practice to explicitly set the $table name, even if it matches Laravel’s default naming convention.

class Category extends Model
{
    protected $table = 'categories';
}

✅ Why You Should Do This

1. Consistent, reliable behavior No surprises when Laravel tries to guess table names (especially with irregular plurals or legacy databases).

2. Peace of mind Your models behave predictably, regardless of future Laravel or Doctrine Inflector changes.

3. Slightly faster queries Laravel skips an internal lookup and pluralization step, resulting in minor performance gains.

4. No deprecated warnings (for Laravel < 8) Older Laravel versions may throw:

PHP Deprecated:  The "Doctrine/Common/Inflector/Inflector::pluralize" method is deprecated...

Explicitly setting $table removes that annoyance entirely.


Of course, you can skip this if you prefer Laravel’s defaults — but I personally always set it. In my next project, I’ll probably switch to singular table names, since I’m not a fan of the plural ones. This older project, however, will stick with plural names, but with explicitly defined tables for consistency.