Skip to content

Commit

Permalink
Added method pluck in BaseRepository
Browse files Browse the repository at this point in the history
  • Loading branch information
eullercdr committed Mar 3, 2017
1 parent d99a625 commit 8806bd2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/Prettus/Repository/Contracts/RepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,23 @@ interface RepositoryInterface
/**
* Retrieve data array for populate field select
*
* @param string $column
* @param string $column
* @param string|null $key
*
* @return \Illuminate\Support\Collection|array
*/
public function lists($column, $key = null);

/**
* Retrieve data array for populate field select
* Compatible with Laravel 5.3
* @param string $column
* @param string|null $key
*
* @return \Illuminate\Support\Collection|array
*/
public function pluck($column, $key = null);

/**
* Retrieve all data of repository
*
Expand All @@ -30,7 +40,7 @@ public function all($columns = ['*']);
/**
* Retrieve all data of repository, paginated
*
* @param null $limit
* @param null $limit
* @param array $columns
*
* @return mixed
Expand All @@ -40,7 +50,7 @@ public function paginate($limit = null, $columns = ['*']);
/**
* Retrieve all data of repository, simple paginated
*
* @param null $limit
* @param null $limit
* @param array $columns
*
* @return mixed
Expand Down
15 changes: 15 additions & 0 deletions src/Prettus/Repository/Eloquent/BaseRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,21 @@ public function lists($column, $key = null)
return $this->model->lists($column, $key);
}

/**
* Retrieve data array for populate field select
* Compatible with Laravel 5.3
* @param string $column
* @param string|null $key
*
* @return \Illuminate\Support\Collection|array
*/
public function pluck($column, $key = null)
{
$this->applyCriteria();

return $this->model->pluck($column, $key);
}

/**
* Retrieve all data of repository
*
Expand Down

0 comments on commit 8806bd2

Please sign in to comment.