问题标签 [pluck]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
210 浏览

laravel-5 - Laravel5.3:如何在 bindign Form::select 元素的关系中使用 pluck?

这是我的模型:

如何pluck()getById()函数中使用列出索引关系?

0 投票
2 回答
3615 浏览

laravel - Laravel 集合:只返回关系和键

我有一个类似于这样的集合:

这将返回以下集合:

我想要做的是通过它们的 id 来键入父项,并且只返回关系。例如

我似乎无法让它发挥作用。我尝试了很多变化,包括:

这不起作用,因为“Pluck”显然是在寻找父模型的名称为“sub”的属性,它不会退出。有没有办法做到这一点?

谢谢

0 投票
0 回答
458 浏览

php - Laravel 5.4 加入 concat pluck

我正在为生物数据记录编写分配系统。数据表:

Assignment.add 的控制器如下:我将使用它来选择并将 bio id 保存到 preceptorids //我不确定这是否是 laravel 的好方法

预期结果:前端

预期结果:后端

但是当我 dd($preceptor); 它只显示 bio_chaya 而不是 preceptorids_id

我是 laravel 的新手,所以任何给定的指南都会很棒。

0 投票
1 回答
208 浏览

hook - How does pluck hook work in feathersjs

In the feathersjs docs the explanation provided is as follows:

pluck discards all fields except for the specified ones, either from the data submitted or from the result. If the data is an array or a paginated find result the hook will remove the field(s) for every item.

The getItems utility returns the items in either hook.data or hook.result depending on whether the hook is being used as a before or after hook. hook.result.data or hook.result is returned for a find method.

The returned items are always an array to simplify further processing.

The replaceItems utility is the reverse of getItems , returning the items where they came from.

My question relates to the checkContextIf function. This function prevents the pluck hook from being called except before the create,update and patch methods. How then does the pluck hook work on the results of the query. Are not the results produced after the service call and handled in an after hook?

0 投票
3 回答
8240 浏览

php - Laravel pluck 数组到字符串的转换

我正在创建投诉为此,在为他们的投诉插入部门时,我正在使用 pluck() 方法从部门表中检索数据并在选择下拉列表中将投诉显示为数组,但问题是它不像它所说的那样工作

数组到字符串的转换(查看:C:\xampp\htdocs\test\resources\views\complaint\create.blade.php)

投诉控制器

创建.blade.php

请帮忙!

0 投票
1 回答
2030 浏览

php - 有没有办法用其内容的索引(重新)映射 Laravel 集合?

我有一些时事通讯:

这导致了这个集合:

在此处输入图像描述

我尝试使用 pluck,但它只允许一列:

$newsletters = $channel->Newsletter()->whereIn('id', $wantNewsletters)->pluck('media', 'id');

在此处输入图像描述

我试图实现的是这个(请原谅我悲伤的油漆店技能:D) 在此处输入图像描述

在某种程度上,就像->pluck('*', 'id'). 现在我不得不 foreach 每个集合,这对我来说似乎不合适。

谢谢你的帮助!

0 投票
1 回答
1513 浏览

php - Laravel5:如何在将分页数据传递给刀片之前访问它

我用

现在,我想在将其传递给刀片之前pluck()将此数据。这不起作用:

当我用

我可以$collection = collect($merchants);毫无问题地使用,但分页肯定不起作用。

那么,在将分页数据传递给刀片之前,如何结合paginate()collect()访问控制器中的分页数据?

0 投票
2 回答
598 浏览

arrays - Laravel 5.4 跳过 Pluck 数组中的第一个值

我有这个查询

这将输出类似

我需要跳过第一个像

请问如何做到这一点?

0 投票
1 回答
218 浏览

ruby-on-rails - Rails 从关联的表中提取

我有两张桌子样本

和丰富

在丰度控制器中,我进行了一次搜查

在丰度视图中,我有一个基于 ransack 参数的过滤表。

示例表有一个字段,当通过对应于上面过滤的参数时,我想在丰度视图中拉出比赛。

我尝试在视图中使用 pluck

但我得到一个错误。不确定我是否以正确的方式进行此操作,或者我的语法是否不正确。

谢谢!

0 投票
1 回答
704 浏览

mysql - Eloquent:使用已删除的条目检索 pluck 集合

我想用 pluck 获取所有地址 ID,包括已删除的地址 ID。这就是它的工作方式,但我也没有得到那些被丢弃的......:

这是我已经尝试过的:

抛出:Method withTrashed does not exist.

如何使用 pluck 和 withTrashed() 来解决这个问题?

亲切的问候!