use Illuminate\Database\Eloquent\Model; class Book extends Model { /** * Get the table associated with the model. * * @return string */ public function getTable() { return 'books'; } }
use Illuminate\Database\Eloquent\Model; class User extends Model { // ... } $user = new User; $table = $user->getTable(); echo $table; // outputs 'users'In this example, we create a new instance of the `User` model and call the `getTable` method on the instance. The returned value is the string `users`, which is the name of the database table associated with the `User` model. The `getTable` method belongs to the `Illuminate\Database\Eloquent\Model` class which is part of the Laravel Eloquent ORM package.