Nestable\Services\NestableService::make PHP Метод

make() публичный Метод

Set the data to wrap class.
public make ( mixed $data ) : object
$data mixed
Результат object (instance)
    public function make($data)
    {
        if ($data instanceof Collection) {
            $this->data = collect($data->toArray());
        } elseif (is_array($data)) {
            $this->data = collect($data);
        } else {
            throw new InvalidArgumentException('Invalid data type.');
        }
        $this->config = Config::get('nestable');
        $this->parent = $this->config['parent'];
        $this->primary_key = $this->config['primary_key'];
        return $this;
    }

Usage Example

Пример #1
0
 /**
  * Pass data to nest methods.
  *
  * @return mixed
  */
 protected function to()
 {
     if (static::$to === 1) {
         $method = 'renderAsArray';
     } elseif (static::$to === 2) {
         $method = 'renderAsJson';
     } elseif (static::$to === 3) {
         $method = 'renderAsHtml';
     } elseif (static::$to === 4) {
         $method = 'renderAsDropdown';
     } else {
         return $this->source;
     }
     $nest = new NestableService();
     $nest->save(static::$parameters);
     $nestable = $nest->make($this->source);
     static::$nested = false;
     return call_user_func([$nestable, $method]);
 }