return "<?php echo \$__env->make('" . self::NAMESPACE . "::favicon', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>";
});
+
$this->app->extend('crud', function () {
return new CubistCrudPanel();
});
*/
public function register()
{
+ $resourcesDir = __DIR__ . '/resources';
+
+ $configs = ['app', 'cubist'];
+
+ foreach ($configs as $config) {
+ $this->mergeConfigFrom($resourcesDir . '/config/' . $config . '.php', $config);
+ }
+
+
$this->commands([
InstallCommand::class,
UpdateCommand::class,
namespace Cubist\Backpack\app\Magic\Fields;
-use Cubist\Backpack\app\Magic\Models\CubistMagicAbstractModel;
+use Illuminate\Support\Str;
class RolesPermissions extends Field
{
protected $fakeColumns = [];
- /**
- * @var Field[]
- */
- protected $_relationships = [];
-
-
/**
* @var array
*/
{
$field = $this->bunchAddField($attributes);
$field->setModelInstance($this);
- if (is_callable([$field, 'getRelationship']) && null !== $field->getRelationship()) {
- $this->_addRelationship($field);
- }
-
$name = $field->getAttribute('name');
if ($field->getAttribute('fake', false) === true) {
}
$table->setPrimaryKey([$this->primaryKey], 'pk_' . $this->table);
-
- foreach ($this->_relationships as $relationship) {
- if ($relationship->getRelationship() === 'belongsToMany') {
-
- $model = self::_toModel($relationship->getAttribute('model'));
-
- $reltable = $schema->createTable($this->getRelationShipTable($relationship));
- $reltable->addColumn('id', 'integer', ['autoincrement' => true, 'unsigned' => true]);
- $reltable->setPrimaryKey(['id']);
- $reltable->addColumn($this->getForeignKey(), 'integer', ['unsigned' => true]);
- $reltable->addColumn($model->getForeignKey(), 'integer', ['unsigned' => true]);
- $this->_addTimestampsDatabaseColumns($reltable);
- }
- }
-
foreach ($this->_fields as $field) {
- if ($field->getRelationship() === 'belongsToMany') {
- continue;
- }
- if ($field->getAttribute('fake', false) !== false) {
+ if ($field->getAttribute('fake', false) !== false) {
continue;
}
$field->defineDbColumn($table);
$table->addColumn('deleted_at', 'datetime', $options);
}
-// public function __call($method, $parameters)
-// {
-//
-// // Set mutators
-// if (preg_match('/^set([a-zA-Z0-9]+)Attribute$/', $method, $matches)) {
-// $attr = Str::snake($matches[1]);
-//
-// if (isset($this->_fields[$attr])) {
-// $callback = [$this->_fields[$attr], 'setMutator'];
-// if (is_callable($callback)) {
-// return call_user_func_array($callback, $parameters);
-// }
-// }
-// }
-//
-// // magic call of relationships
-// foreach ($this->_relationships as $relationship) {
-// /** @var $relationship Field */
-// if ($method == $relationship->getAttribute('entity')) {
-// return $this->relationship($relationship);
-// }
-// }
-//
-// return parent::__call($method, $parameters);
-// }
-//
-// /**
-// * @param $field Field|string
-// * @return \Illuminate\Database\Eloquent\Relations\BelongsTo|\Illuminate\Database\Eloquent\Relations\BelongsToMany
-// */
-// public function relationship($field)
-// {
-// if (is_string($field)) {
-// foreach ($this->_fields as $f) {
-// if ($f->getAttribute('entity') == $field) {
-// $field = $f;
-// break;
-// }
-// }
-// }
-// switch ($field->getRelationship()) {
-// case 'belongsTo':
-// return $this->belongsTo($field->getAttribute('model'), $field->getAttribute('name'));
-// case 'belongsToMany':
-// return $this->belongsToMany($field->getAttribute('model'), $this->getRelationShipTable($field));
-// }
-// }
-//
-// /**
-// * @param $field Field
-// * @return string
-// */
-// public function getRelationShipTable($field)
-// {
-// /** @var Model $foreignEntity */
-// $foreignEntity = self::_toModel($field->getAttribute('model'));
-//
-// if ($field->getRelationship() == 'belongsToMany') {
-// return $this->getTable() . '_' . $field->getAttribute('name') . '_rel_btm';
-// }
-// }
-
/**
* @param $class Model|string
* @return Model
'type' => 'checkbox',
'tab' => 'Login']);
- $this->addField(['name' => 'permissions',
- 'label' => '',
- 'type' => 'RolesPermissions',
- 'tab' => 'Roles & Permissions']);
+// $this->addField(['name' => 'permissions',
+// 'label' => '',
+// 'type' => 'RolesPermissions',
+// 'tab' => 'Roles & Permissions']);
$this->addField(['name' => 'remember_token',
'type' => 'Text',
--- /dev/null
+<?php
+return [
+ 'aliases' => [
+ 'App' => Cubist\Backpack\app\Facades\App::class,
+ 'Arr' => Illuminate\Support\Arr::class,
+ 'Str' => Illuminate\Support\Str::class,
+ ],
+];
?>
<div class="bunch__margin col-xs-12">
<div class="bunch__wrapper col-xs-12">
- <div @include('crud::inc.field_wrapper_attributes') >
- <label>{!! $field['label'] !!}</label>
- @include('crud::inc.field_translatable_icon')
- <div class="clearfix"></div>
+ @include('crud::fields.inc.wrapper_start')
+ <label>{!! $field['label'] !!}</label>
+ @include('crud::fields.inc.translatable_icon')
+ <div class="clearfix"></div>
- @include('cubist_back::inc.show_bunch_fields', array('bunchfields'=>$field['bunchfields']))
+ @include('cubist_back::inc.show_bunch_fields', array('bunchfields'=>$field['bunchfields']))
- <div class="clearfix"></div>
+ <div class="clearfix"></div>
- {{-- HINT --}}
- @if (isset($field['hint']))
- <p class="help-block">{!! $field['hint'] !!}</p>
- @endif
- </div>
+ {{-- HINT --}}
+ @if (isset($field['hint']))
+ <p class="help-block">{!! $field['hint'] !!}</p>
+ @endif
+ @include('crud::fields.inc.wrapper_end')
</div>
</div>
<div class="bunchmultiple" id="{!! $field['rand'] !!}" data-values="{{ $value }}">
<input type="hidden" class="hiddenfield" name="{{$field['name']}}" value="{{ $value }}" data-bmid="{!! $field['rand'] !!}"/>
<div class="bunchmultiple__wrapper" data-bmid="{!! $field['rand'] !!}">
- <div @include('crud::inc.field_wrapper_attributes') >
+ @include('crud::fields.inc.wrapper_start')
<label>{!! $field['label'] !!}</label>
- @include('crud::inc.field_translatable_icon')
+ @include('crud::fields.inc.translatable_icon')
<div class="clearfix"></div>
<div class="bunchmultiple__items" data-bmid="{!! $field['rand'] !!}">
@if (isset($field['hint']))
<p class="help-block">{!! $field['hint'] !!}</p>
@endif
- </div>
+ @include('crud::fields.inc.wrapper_end')
</div>
</div>
?>
-<div @include('crud::inc.field_wrapper_attributes') >
+@include('crud::fields.inc.wrapper_start')
<label>{!! $field['label'] !!}</label>
- @include('crud::inc.field_translatable_icon')
+ @include('crud::fields.inc.translatable_icon')
<div class="clearfix"></div>
<div class="button__wrapper">
<div class="col-sm-3 button__field hideifdisabled">
<p class="help-block">{!! $field['hint'] !!}</p>
@endif
-</div>
+@include('crud::fields.inc.wrapper_end')
{{-- ########################################## --}}
<!-- html5 color input -->
-<div @include('crud::inc.field_wrapper_attributes') >
+@include('crud::fields.inc.wrapper_start')
<label>{!! $field['label'] !!}</label>
- @include('crud::inc.field_translatable_icon')
+ @include('crud::fields.inc.translatable_icon')
<input
type="text"
class="spectrum"
name="{{ $field['name'] }}"
value="{{ old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $field['default'] ?? '' }}"
- @include('crud::inc.field_attributes')
+ @include('crud::fields.inc.attributes')
>
{{-- HINT --}}
@if (isset($field['hint']))
<p class="help-block">{!! $field['hint'] !!}</p>
@endif
-</div>
+@include('crud::fields.inc.wrapper_end')
{{-- ########################################## --}}
{{-- Extra CSS and JS for this particular field --}}
@php
- // if not otherwise specified, the hidden input should take up no space in the form
- if (!isset($field['wrapperAttributes']) || !isset($field['wrapperAttributes']['class']))
- {
- $field['wrapperAttributes']['class'] = "hidden";
- }
+ // if not otherwise specified, the hidden input should take up no space in the form
+ $field['wrapper']['class'] = $field['wrapper']['class'] ?? $field['wrapperAttributes']['class'] ?? "hidden";
@endphp
<!-- hidden input -->
-<div @include('crud::inc.field_wrapper_attributes') >
- <input
- type="hidden"
+@include('crud::fields.inc.wrapper_start')
+<input
+ type="hidden"
name="{{ $field['name'] }}"
value="{{ old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $field['default'] ?? '' }}"
- @include('crud::inc.field_attributes')
- >
-</div>
\ No newline at end of file
+ @include('crud::fields.inc.attributes')
+>
+@include('crud::fields.inc.wrapper_end')
}
?>
-<div @include('crud::inc.field_wrapper_attributes') >
+@include('crud::fields.inc.wrapper_start')
<label>{!! $field['label'] !!}</label>
<div class="rangeofvalues__wrapper">
<div class="rangeofvalues__field">
<div class="input-group"> @endif
@if(isset($field['prefix']))
<div class="input-group-addon">{!! $field['prefix'] !!}</div> @endif
- <input @include('crud::inc.field_attributes')
+ <input @include('crud::fields.inc.attributes')
value="{{ $value['first'] }}"
type="number"
name="{{ $field['name'] }}[first]"
@if(isset($field['prefix']))
<div class="input-group-addon">{!! $field['prefix'] !!}</div> @endif
- <input @include('crud::inc.field_attributes')
+ <input @include('crud::fields.inc.attributes')
value="{{ $value['second'] }}"
type="number"
name="{{ $field['name'] }}[second]"
@if (isset($field['hint']))
<p class="help-block">{!! $field['hint'] !!}</p>
@endif
-</div>
+@include('crud::fields.inc.wrapper_end')
@if ($crud->checkIfFieldIsFirstOfItsType($field))
{{-- FIELD EXTRA CSS --}}
@endphp
<!-- select2 from array -->
-<div @include('crud::inc.field_wrapper_attributes') >
+@include('crud::fields.inc.wrapper_start')
<label>{!! $field['label'] !!}</label>
<select
name="{{ $field['name'] }}@if (isset($field['allows_multiple']) && $field['allows_multiple']==true)[]@endif"
style="width: 100%"
- @include('crud::inc.field_attributes', ['default_class' => 'form-control select2_from_array'])
+ @include('crud::fields.inc.attributes', ['default_class' => 'form-control select2_from_array'])
@if (isset($field['allows_multiple']) && $field['allows_multiple']==true)multiple @endif
>
@if (isset($field['hint']))
<p class="help-block">{!! $field['hint'] !!}</p>
@endif
-</div>
+@include('crud::fields.inc.wrapper_end')
{{-- ########################################## --}}
{{-- Extra CSS and JS for this particular field --}}
$values = isset($field['value']) ? (array)$field['value'] : [];
@endphp
-<div @include('crud::inc.field_wrapper_attributes') >
+@include('crud::fields.inc.wrapper_start')
<label>{!! $field['label'] !!}</label>
- @include('crud::inc.field_translatable_icon')
+ @include('crud::fields.inc.translatable_icon')
<div>
<ul id="{{ $field['name'] }}_selected" class="{{ $field['name'] }}_connectedSortable select_and_order_selected pull-left">
@if(old($field["name"]))
@if (isset($field['hint']))
<p class="help-block">{!! $field['hint'] !!}</p>
@endif
-</div>
+@include('crud::fields.inc.wrapper_end')
{{-- ########################################## --}}
<!-- Simple MDE - Markdown Editor -->
-<div @include('crud::inc.field_wrapper_attributes') >
+@include('crud::fields.inc.wrapper_start')
<label>{!! $field['label'] !!}</label>
- @include('crud::inc.field_translatable_icon')
+ @include('crud::fields.inc.translatable_icon')
<textarea
class="simplemde_area" name="{{ $field['name'] }}"
data-simplemdeattrs="{{json_encode($field['simplemdeAttributes'])}}"
- @include('crud::inc.field_attributes', ['default_class' => 'form-control'])
+ @include('crud::fields.inc.attributes', ['default_class' => 'form-control'])
>{{ old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $field['default'] ?? '' }}</textarea>
{{-- HINT --}}
@if (isset($field['hint']))
<p class="help-block">{!! $field['hint'] !!}</p>
@endif
-</div>
+@include('crud::fields.inc.wrapper_end')
{{-- ########################################## --}}
$values = $normalizedValues;
?><!-- select2 tags -->
-<div @include('crud::inc.field_wrapper_attributes') >
+@include('crud::fields.inc.wrapper_start')
<label>{!! $field['label'] !!}</label>
- @include('crud::inc.field_translatable_icon')
+@include('crud::fields.inc.translatable_icon')
@if(isset($field['prefix']) || isset($field['suffix']))
<div class="input-group"> @endif
<select
name="{{ $field['name'] }}[]"
style="width: 100%"
- @include('crud::inc.field_attributes', ['default_class' => 'form-control select2_tags'])
+ @include('crud::fields.inc.attributes', ['default_class' => 'form-control select2_tags'])
multiple>
@foreach($values as $value)
<option name="{{$value}}" selected>{{$value}}</option>
@if (isset($field['hint']))
<p class="help-block">{!! $field['hint'] !!}</p>
@endif
-</div>
+@include('crud::fields.inc.wrapper_end')
{{-- ########################################## --}}
<!-- text input -->
-<div @include('crud::inc.field_wrapper_attributes') >
+@include('crud::fields.inc.wrapper_start')
<label>{!! $field['label'] !!}</label>
- @include('crud::inc.field_translatable_icon')
+ @include('crud::fields.inc.translatable_icon')
@if(isset($field['prefix']) || isset($field['suffix'])) <div class="input-group"> @endif
- @if(isset($field['prefix'])) <div class="input-group-addon">{!! $field['prefix'] !!}</div> @endif
+ @if(isset($field['prefix'])) <div class="input-group-prepend"><span class="input-group-text">{!! $field['prefix'] !!}</span></div> @endif
<input
type="text"
name="{{ $field['name'] }}"
value="{{ old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $field['default'] ?? '' }}"
- @include('crud::inc.field_attributes')
+ @include('crud::fields.inc.attributes')
>
- @if(isset($field['suffix'])) <div class="input-group-addon">{!! $field['suffix'] !!}</div> @endif
+ @if(isset($field['suffix'])) <div class="input-group-append"><span class="input-group-text">{!! $field['suffix'] !!}</span></div> @endif
@if(isset($field['prefix']) || isset($field['suffix'])) </div> @endif
{{-- HINT --}}
<p class="help-block">{!! $field['hint'] !!}</p>
@endif
</div>
-
-
-{{-- FIELD EXTRA CSS --}}
-{{-- push things in the after_styles section --}}
-
-{{-- @push('crud_fields_styles')
- <!-- no styles -->
-@endpush --}}
-
-
-{{-- FIELD EXTRA JS --}}
-{{-- push things in the after_scripts section --}}
-
-{{-- @push('crud_fields_scripts')
- <!-- no scripts -->
-@endpush --}}
-
-
-{{-- Note: you can use @if ($crud->checkIfFieldIsFirstOfItsType($field, $fields)) to only load some CSS/JS once, even though there are multiple instances of it --}}