Automatically detect eloquent table names.
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user