Commit 17727a22 authored by Taylor Otwell's avatar Taylor Otwell

rename eloquent::model to eloquent::model_name

parent 914b60e2
...@@ -79,7 +79,7 @@ class Auth { ...@@ -79,7 +79,7 @@ class Auth {
* by the Hash class when authenticating. * by the Hash class when authenticating.
* *
* <code> * <code>
* if (Auth::attempt('test@gmail.com', 'secret')) * if (Auth::login('test@gmail.com', 'secret'))
* { * {
* // The credentials are valid... * // The credentials are valid...
* } * }
...@@ -90,13 +90,13 @@ class Auth { ...@@ -90,13 +90,13 @@ class Auth {
* @return bool * @return bool
* @see Hash::check() * @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 ( ! is_null($user = call_user_func(Config::get('auth.by_username'), $username)))
{ {
if (Hash::check($password, $user->password)) if (Hash::check($password, $user->password))
{ {
static::login($user); static::remember($user);
return true; return true;
} }
...@@ -106,7 +106,7 @@ class Auth { ...@@ -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 * The user's ID will be stored in the session and the user will be considered
* "logged in" on subsequent requests to the application. * "logged in" on subsequent requests to the application.
...@@ -116,7 +116,7 @@ class Auth { ...@@ -116,7 +116,7 @@ class Auth {
* @param object $user * @param object $user
* @return void * @return void
*/ */
public static function login($user) public static function remember($user)
{ {
static::$user = $user; static::$user = $user;
......
...@@ -150,7 +150,7 @@ abstract class Model { ...@@ -150,7 +150,7 @@ abstract class Model {
{ {
if (property_exists($class, 'table')) return $class::$table; 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 { ...@@ -159,7 +159,7 @@ abstract class Model {
* @param string|Model $model * @param string|Model $model
* @return string * @return string
*/ */
public static function model($model) public static function model_name($model)
{ {
$class = (is_object($model)) ? get_class($model) : $model; $class = (is_object($model)) ? get_class($model) : $model;
...@@ -268,7 +268,7 @@ abstract class Model { ...@@ -268,7 +268,7 @@ abstract class Model {
*/ */
private function has_one_or_many($model, $foreign_key) 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); return static::query($model)->where($this->relating_key, '=', $this->id);
} }
...@@ -322,11 +322,11 @@ abstract class Model { ...@@ -322,11 +322,11 @@ abstract class Model {
// Allowing the overriding of the foreign and associated keys provides the flexibility for // Allowing the overriding of the foreign and associated keys provides the flexibility for
// self-referential many-to-many relationships, such as a "buddy list". // 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 // 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". // 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) return static::query($model)
->select(array(static::table($model).'.*')) ->select(array(static::table($model).'.*'))
...@@ -345,7 +345,7 @@ abstract class Model { ...@@ -345,7 +345,7 @@ abstract class Model {
*/ */
private function intermediate_table($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); sort($models);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment