only() public method

Get the items with the specified keys.
public only ( mixed $keys ) : static
$keys mixed
return static
 /**
  * @param array| string $keys
  *
  * @return FieldInterface[]|Collection
  */
 public function getOnly($keys)
 {
     if (!is_array($keys)) {
         $keys = func_get_args();
     }
     return $this->fields->only($keys);
 }
Example #2
0
 public function testOnly()
 {
     $data = new Collection(['first' => 'Taylor', 'last' => 'Otwell', 'email' => '*****@*****.**']);
     $this->assertEquals(['first' => 'Taylor'], $data->only(['first', 'missing'])->all());
     $this->assertEquals(['first' => 'Taylor'], $data->only('first', 'missing')->all());
     $this->assertEquals(['first' => 'Taylor', 'email' => '*****@*****.**'], $data->only(['first', 'email'])->all());
     $this->assertEquals(['first' => 'Taylor', 'email' => '*****@*****.**'], $data->only('first', 'email')->all());
 }
Example #3
0
 /**
  * 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());
 }