本文整理汇总了PHP中Illuminate\Support\Collection::only方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::only方法的具体用法?PHP Collection::only怎么用?PHP Collection::only使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Collection
的用法示例。
在下文中一共展示了Collection::only方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOnly
/**
* @param array| string $keys
*
* @return FieldInterface[]|Collection
*/
public function getOnly($keys)
{
if (!is_array($keys)) {
$keys = func_get_args();
}
return $this->fields->only($keys);
}
示例2: testOnly
public function testOnly()
{
$data = new Collection(['first' => 'Taylor', 'last' => 'Otwell', 'email' => 'taylorotwell@gmail.com']);
$this->assertEquals(['first' => 'Taylor'], $data->only(['first', 'missing'])->all());
$this->assertEquals(['first' => 'Taylor'], $data->only('first', 'missing')->all());
$this->assertEquals(['first' => 'Taylor', 'email' => 'taylorotwell@gmail.com'], $data->only(['first', 'email'])->all());
$this->assertEquals(['first' => 'Taylor', 'email' => 'taylorotwell@gmail.com'], $data->only('first', 'email')->all());
}
示例3: modelTenants
/**
* Get the tenantColumns that are actually applicable to the given
* model, in case they've been manually specified.
*
* @param Model|BelongsToTenants $model
*
* @return Collection
*/
protected function modelTenants(Model $model)
{
return $this->tenants->only($model->getTenantColumns());
}