return Arr::get($this->_attributes, $key, $default);
}
+ public function unsetAttribute($key)
+ {
+ $this->setAttribute($key, null);
+ }
+
public function hasAttribute($key)
{
$key = $this->_attribute($key);
{
return [];
}
+
+ public function offsetSet($offset, $value)
+ {
+ if (is_null($offset)) {
+
+ } else {
+ $this->setAttribute($offset, $value);
+ }
+ }
+
+ public function offsetExists($offset)
+ {
+ return $this->hasAttribute($offset);
+ }
+
+ public function offsetUnset($offset)
+ {
+ $this->unsetAttribute($offset);
+ }
+
+ public function offsetGet($offset)
+ {
+ return $this->getAttribute($offset, null);
+ }
}
namespace Cubist\Backpack\app\Magic\Fields;
+use Cubist\Backpack\CubistBackpackServiceProvider;
+
class BunchOfFields extends Field
{
use \Cubist\Backpack\app\Magic\BunchOfFields;
+ protected $_adminType = 'bunch';
+ protected $_cast = 'array';
+ protected $_viewNamespace = CubistBackpackServiceProvider::NAMESPACE . '::fields';
+
public function getDefaultAttributes()
{
return array_merge(parent::getDefaultAttributes(), ['bunch' => []]);
}
}
}
+
+ foreach ($this->_fields as $field) {
+ $name = $field->getAttribute('name');
+ $e = explode('[', $name);
+ $main = array_shift($e);
+ $name = $this->getAttribute('name') . '[' . $main . ']';
+ foreach ($e as $item) {
+ $name .= '[' . $item . ']';
+ }
+ $field->setAttribute('name', $name);
+ }
+ $this->setAttribute('bunchfields', $this->getFields());
}
}
use Illuminate\Support\Str;
use Cubist\Backpack\app\Magic\Models\CubistMagicAbstractModel;
-class Field
+class Field implements \ArrayAccess
{
use CubistMagicAttribute;
protected $_attributes;
--- /dev/null
+<?php
+
+
+namespace app\PageManager\Models;
+
+
+use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
+
+class Page extends \Backpack\PageManager\app\Models\Page
+{
+ use HasMediaTrait;
+}
--- /dev/null
+<!-- Bunch -->
+
+<?php
+
+
+?>
+
+<div @include('crud::inc.field_wrapper_attributes') >
+ <label>{!! $field['label'] !!}</label>
+ @include('crud::inc.field_translatable_icon')
+ <div class="clearfix"></div>
+
+ @include('crud::inc.show_fields', array('fields'=>$field['bunchfields']))
+
+ <div class="clearfix"></div>
+
+ {{-- HINT --}}
+ @if (isset($field['hint']))
+ <p class="help-block">{!! $field['hint'] !!}</p>
+ @endif
+
+</div>
+
+
+{{-- ########################################## --}}
+{{-- Extra CSS and JS for this particular field --}}
+{{-- If a field type is shown multiple times on a form, the CSS and JS will only be loaded once --}}
+@if ($crud->checkIfFieldIsFirstOfItsType($field))
+
+ {{-- FIELD CSS - will be loaded in the after_styles section --}}
+ @push('crud_fields_styles')
+ <style type="text/css">
+
+ </style>
+ @endpush
+
+ {{-- FIELD JS - will be loaded in the after_scripts section --}}
+ @push('crud_fields_scripts')
+ <script>
+ jQuery(document).ready(function ($) {
+
+
+ });
+ </script>
+ @endpush
+
+@endif
+{{-- End of Extra CSS and JS --}}
+{{-- ########################################## --}}