diff --git a/laravel/database/eloquent/query.php b/laravel/database/eloquent/query.php index 3aee79c9..2d162e8e 100644 --- a/laravel/database/eloquent/query.php +++ b/laravel/database/eloquent/query.php @@ -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. *