DEV Community

David Lun
David Lun

Posted on β€’ Edited on

1

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)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs