Automatically detect eloquent table names.

This commit is contained in:
Taylor Otwell
2012-03-19 14:11:11 -05:00
parent 26afb000bf
commit e540fd3b6d
2 changed files with 14 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
<?php namespace Laravel\Database\Eloquent;
use Laravel\Str;
use Laravel\Database;
use Laravel\Database\Eloquent\Relationships\Has_Many_And_Belongs_To;
@@ -418,6 +419,16 @@ abstract class Model {
return ! $this->exists or $this->original !== $this->attributes;
}
/**
* Get the name of the table associated with the model.
*
* @return string
*/
public function table()
{
return static::$table ?: strtolower(Str::plural(basename(get_class($this))));
}
/**
* Get the dirty attributes for the model.
*