DEV Community

David Lun
David Lun

Posted on • Edited on

How to get Laravel model table statically

namespace App\Models\Traits;

trait CanGetTableNameStatically
{
    public static function table()
    {
        return with(new static())->getTable();
    }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)