rename eloquent::model to eloquent::model_name

This commit is contained in:
Taylor Otwell 2011-08-13 20:01:45 -05:00
parent 914b60e20b
commit 17727a2278
2 changed files with 11 additions and 11 deletions

View File

@ -79,7 +79,7 @@ class Auth {
* by the Hash class when authenticating.
*
* <code>
* if (Auth::attempt('test@gmail.com', 'secret'))
* if (Auth::login('test@gmail.com', 'secret'))
* {
* // The credentials are valid...
* }
@ -90,13 +90,13 @@ class Auth {
* @return bool
* @see Hash::check()
*/
public static function attempt($username, $password)
public static function login($username, $password)
{
if ( ! is_null($user = call_user_func(Config::get('auth.by_username'), $username)))
{
if (Hash::check($password, $user->password))
{
static::login($user);
static::remember($user);
return true;
}
@ -106,7 +106,7 @@ class Auth {
}
/**
* Login a given user into the application.
* Log a user into the application without checking credentials.
*
* The user's ID will be stored in the session and the user will be considered
* "logged in" on subsequent requests to the application.
@ -116,7 +116,7 @@ class Auth {
* @param object $user
* @return void
*/
public static function login($user)
public static function remember($user)
{
static::$user = $user;

View File

@ -150,7 +150,7 @@ abstract class Model {
{
if (property_exists($class, 'table')) return $class::$table;
return strtolower(Inflector::plural(static::model($class)));
return strtolower(Inflector::plural(static::model_name($class)));
}
/**
@ -159,7 +159,7 @@ abstract class Model {
* @param string|Model $model
* @return string
*/
public static function model($model)
public static function model_name($model)
{
$class = (is_object($model)) ? get_class($model) : $model;
@ -268,7 +268,7 @@ abstract class Model {
*/
private function has_one_or_many($model, $foreign_key)
{
$this->relating_key = (is_null($foreign_key)) ? strtolower(static::model($this)).'_id' : $foreign_key;
$this->relating_key = (is_null($foreign_key)) ? strtolower(static::model_name($this)).'_id' : $foreign_key;
return static::query($model)->where($this->relating_key, '=', $this->id);
}
@ -322,11 +322,11 @@ abstract class Model {
// Allowing the overriding of the foreign and associated keys provides the flexibility for
// self-referential many-to-many relationships, such as a "buddy list".
$this->relating_key = (is_null($foreign_key)) ? strtolower(static::model($this)).'_id' : $foreign_key;
$this->relating_key = (is_null($foreign_key)) ? strtolower(static::model_name($this)).'_id' : $foreign_key;
// The associated key is the foreign key name of the related model. So, if the related model
// is "Role", the associated key on the intermediate table would be "role_id".
$associated_key = (is_null($associated_key)) ? strtolower(static::model($model)).'_id' : $associated_key;
$associated_key = (is_null($associated_key)) ? strtolower(static::model_name($model)).'_id' : $associated_key;
return static::query($model)
->select(array(static::table($model).'.*'))
@ -345,7 +345,7 @@ abstract class Model {
*/
private function intermediate_table($model)
{
$models = array(Inflector::plural(static::model($model)), Inflector::plural(static::model($this)));
$models = array(Inflector::plural(static::model_name($model)), Inflector::plural(static::model_name($this)));
sort($models);