lists > pluck

This commit is contained in:
Daniel Klabbers 2017-10-05 13:39:41 +02:00
parent 399ff616ff
commit 5b6ee0181a
13 changed files with 33 additions and 33 deletions

View File

@ -20,24 +20,24 @@
"docs": "http://flarum.org/docs"
},
"require": {
"php": ">=5.6.0",
"php": ">=7.0",
"dflydev/fig-cookies": "^1.0.2",
"doctrine/dbal": "^2.5",
"components/font-awesome": "^4.6",
"franzl/whoops-middleware": "^0.4.0",
"illuminate/bus": "5.1.*",
"illuminate/cache": "5.1.*",
"illuminate/config": "5.1.*",
"illuminate/container": "5.1.*",
"illuminate/contracts": "5.1.*",
"illuminate/database": "^5.1.31",
"illuminate/events": "5.1.*",
"illuminate/filesystem": "5.1.*",
"illuminate/hashing": "5.1.*",
"illuminate/mail": "5.1.*",
"illuminate/support": "5.1.*",
"illuminate/validation": "5.1.*",
"illuminate/view": "5.1.*",
"illuminate/bus": "5.5.*",
"illuminate/cache": "5.5.*",
"illuminate/config": "5.5.*",
"illuminate/container": "5.5.*",
"illuminate/contracts": "5.5.*",
"illuminate/database": "5.5.*",
"illuminate/events": "5.5.*",
"illuminate/filesystem": "5.5.*",
"illuminate/hashing": "5.5.*",
"illuminate/mail": "5.5.*",
"illuminate/support": "5.5.*",
"illuminate/validation": "5.5.*",
"illuminate/view": "5.5.*",
"intervention/image": "^2.3.0",
"league/flysystem": "^1.0.11",
"league/oauth2-client": "~1.0",
@ -46,10 +46,10 @@
"nikic/fast-route": "^0.6",
"oyejorge/less.php": "~1.5",
"psr/http-message": "^1.0",
"symfony/console": "^2.7",
"symfony/http-foundation": "^2.7",
"symfony/translation": "^2.7",
"symfony/yaml": "^2.7",
"symfony/console": "^3.3",
"symfony/http-foundation": "^3.3",
"symfony/translation": "^3.3",
"symfony/yaml": "^3.3",
"s9e/text-formatter": "^0.8.1",
"tobscure/json-api": "^0.3.0",
"zendframework/zend-diactoros": "^1.1",
@ -57,7 +57,7 @@
},
"require-dev": {
"mockery/mockery": "^0.9.4",
"phpunit/phpunit": "^4.8"
"phpunit/phpunit": "^6.0"
},
"autoload": {
"psr-4": {

View File

@ -83,7 +83,7 @@ class CreatePostController extends AbstractCreateController
}
$discussion = $post->discussion;
$discussion->posts = $discussion->postsVisibleTo($actor)->orderBy('time')->lists('id');
$discussion->posts = $discussion->postsVisibleTo($actor)->orderBy('time')->pluck('id');
return $post;
}

View File

@ -122,7 +122,7 @@ class ListPostsController extends AbstractListController
$query->orderBy($field, $order);
}
return $query->lists('id')->all();
return $query->pluck('id')->all();
}
/**

View File

@ -117,7 +117,7 @@ class ShowDiscussionController extends AbstractShowController
*/
private function loadPostIds(Discussion $discussion, User $actor)
{
return $discussion->postsVisibleTo($actor)->orderBy('time')->lists('id')->all();
return $discussion->postsVisibleTo($actor)->orderBy('time')->pluck('id')->all();
}
/**

View File

@ -63,7 +63,7 @@ class UpdateDiscussionController extends AbstractShowController
if ($posts = $discussion->getModifiedPosts()) {
$posts = (new Collection($posts))->load('discussion', 'user');
$discussionPosts = $discussion->postsVisibleTo($actor)->orderBy('time')->lists('id')->all();
$discussionPosts = $discussion->postsVisibleTo($actor)->orderBy('time')->pluck('id')->all();
foreach ($discussionPosts as &$id) {
foreach ($posts as $post) {

View File

@ -58,7 +58,7 @@ class DatabaseMigrationRepository implements MigrationRepositoryInterface
return $this->table()
->where('extension', $extension)
->orderBy('migration', 'asc')
->lists('migration');
->pluck('migration');
}
/**

View File

@ -53,7 +53,7 @@ class DiscussionRepository
return Discussion::leftJoin('users_discussions', 'users_discussions.discussion_id', '=', 'discussions.id')
->where('user_id', $user->id)
->where('read_number', '>=', new Expression('last_post_number'))
->lists('id')
->pluck('id')
->all();
}

View File

@ -23,7 +23,7 @@ class MySqlFulltextDriver implements DriverInterface
$discussionIds = Post::where('type', 'comment')
->whereRaw('MATCH (`content`) AGAINST (? IN BOOLEAN MODE)', [$string])
->orderByRaw('MATCH (`content`) AGAINST (?) DESC', [$string])
->lists('discussion_id', 'id');
->pluck('discussion_id', 'id');
$relevantPostIds = [];

View File

@ -106,7 +106,7 @@ class NotificationSyncer
// removed from this collection by the above loop. Un-delete the
// existing records that we want to keep.
if (count($toDelete)) {
$this->setDeleted($toDelete->lists('id')->all(), true);
$this->setDeleted($toDelete->pluck('id')->all(), true);
}
if (count($toUndelete)) {

View File

@ -70,7 +70,7 @@ class PostRepository
$query->orderBy($field, $order);
}
$ids = $query->lists('id')->all();
$ids = $query->pluck('id')->all();
return $this->findByIds($ids, $actor);
}
@ -111,7 +111,7 @@ class PostRepository
*/
public function filterVisibleIds(array $ids, User $actor)
{
return $this->queryIds($ids, $actor)->lists('id')->all();
return $this->queryIds($ids, $actor)->pluck('id')->all();
}
/**

View File

@ -24,7 +24,7 @@ class DatabaseSettingsRepository implements SettingsRepositoryInterface
public function all()
{
return $this->database->table('settings')->lists('value', 'key');
return $this->database->table('settings')->pluck('value', 'key');
}
public function get($key, $default = null)

View File

@ -650,7 +650,7 @@ class User extends AbstractModel
// standard 'member' group, as well as any other groups they've been
// assigned to.
if ($this->is_activated) {
$groupIds = array_merge($groupIds, [Group::MEMBER_ID], $this->groups->lists('id')->all());
$groupIds = array_merge($groupIds, [Group::MEMBER_ID], $this->groups->pluck('id')->all());
}
event(new PrepareUserGroups($this, $groupIds));
@ -665,7 +665,7 @@ class User extends AbstractModel
*/
public function getPermissions()
{
return $this->permissions()->lists('permission')->all();
return $this->permissions()->pluck('permission')->all();
}
/**

View File

@ -94,7 +94,7 @@ class UserRepository
->orderByRaw('username = ? desc', [$string])
->orderByRaw('username like ? desc', [$string.'%']);
return $this->scopeVisibleTo($query, $actor)->lists('id');
return $this->scopeVisibleTo($query, $actor)->pluck('id')->all();
}
/**