@php $field['type'] = 'relationship.morphTo_select'; $optionsForModels = []; foreach($field['morphOptions'] as $model => $modelOptions) { if(isset($modelOptions['data_source']) || ($modelOptions['ajax'] ?? false)) { continue; } if(!is_a($model, 'Illuminate\Database\Eloquent\Model', true)) { $model = $field['morphMap'][$model]; } $modelInstance = new $model; $modelAttribute = $modelOptions['attribute'] ?? $modelInstance->identifiableAttribute(); if(isset($modelOptions['options']) && is_array($modelOptions['options'])) { $optionsForModels[$model] = $modelOptions; continue; } if(is_callable($modelOptions['query'] ?? [])) { $optionsForModels[$model] = ($modelOptions['query'])($modelInstance->toBase())->pluck($modelAttribute, $modelInstance->getKeyName())->toArray(); continue; } $optionsForModels[$model] = $modelInstance->toBase()->pluck($modelAttribute, $modelInstance->getKeyName())->toArray(); } $currentValue = old_empty_or_null($field['name'], '') ?? $field['value'] ?? $field['default'] ?? ''; @endphp @include('crud::fields.inc.wrapper_start') {{-- HINT --}} @if (isset($field['hint']))
{!! $field['hint'] !!}
@endif @include('crud::fields.inc.wrapper_end') {{-- ########################################## --}} {{-- 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 --}} {{-- FIELD CSS - will be loaded in the after_styles section --}} @push('crud_fields_styles') @loadOnce('packages/select2/dist/css/select2.min.css') @loadOnce('packages/select2-bootstrap-theme/dist/select2-bootstrap.min.css') @endpush {{-- FIELD JS - will be loaded in the after_scripts section --}} @push('crud_fields_scripts') @loadOnce('packages/select2/dist/js/select2.full.min.js') @if (app()->getLocale() !== 'en') @loadOnce('packages/select2/dist/js/i18n/' . str_replace('_', '-', app()->getLocale()) . '.js') @endif @endpush @push('crud_fields_scripts') @loadOnce('bpFieldInitMorphToSelectElement') @endLoadOnce @endpush {{-- End of Extra CSS and JS --}} {{-- ########################################## --}}