Skip to content

Commit

Permalink
add file
Browse files Browse the repository at this point in the history
  • Loading branch information
pxpm committed Jun 23, 2020
1 parent f9dbbeb commit 3181af1
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/app/Library/CrudPanel/CrudObjectGroup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace Backpack\CRUD\app\Library\CrudPanel;

class CrudObjectGroup
{
protected $objects;

// init objects in group, supports multiple parameters or array as input.
//
// eg: CRUD::group(CRUD::field('field1'), CRUD::field('field2')); OR
// CRUD::group([
// CRUD::field('field1'),
// CRUD::field('field2'),
// ]);

public function __construct(...$objects)
{
if (is_array($objects[0])) {
$objects = $objects[0];
}

$this->objects = $objects;
}

// -------------
// MAGIC METHODS
// -------------

/**
* We foward any call to the corresponding class passed by developer (Field, Columns, Filters etc ..).
*
* @param string $method The method being called that doesn't exist.
* @param array $parameters The arguments when that method was called.
*
* @return CrudObjectGroup
*/
public function __call($method, $parameter)
{
foreach ($this->objects as $object) {
$object->{$method}($parameter[0]);
}

return $this;
}
}

0 comments on commit 3181af1

Please sign in to comment.