Add the find method to the Eloquent Query class.
Signed-off-by: Jason Lewis <jason.lewis1991@gmail.com>
This commit is contained in:
parent
8ff052cbdb
commit
a68d2242d3
|
@ -50,6 +50,22 @@ public function __construct($model)
|
||||||
$this->table = $this->table();
|
$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.
|
* Get the first model result for the query.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue