Add the find method to the Eloquent Query class.

Signed-off-by: Jason Lewis <jason.lewis1991@gmail.com>
This commit is contained in:
Jason Lewis 2012-12-18 19:14:51 +11:00
parent 8ff052cbdb
commit a68d2242d3
1 changed files with 16 additions and 0 deletions

View File

@ -50,6 +50,22 @@ public function __construct($model)
$this->table = $this->table();
}
/**
* Find a model by its primary key.
*
* @param mixed $id
* @param array $columns
* @return mixed
*/
public function find($id, $columns = array('*'))
{
$model = $this->model;
$this->table->where($model::$key, '=', $id);
return $this->first($columns);
}
/**
* Get the first model result for the query.
*