diff --git a/.travis.yml b/.travis.yml index 34a0767..e46d3d2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ language: php php: - 5.5 - 5.6 - - 7.0 - hhvm before_script: diff --git a/src/Abstractor/Eloquent/Model.php b/src/Abstractor/Eloquent/Model.php index 7463724..cc84da4 100644 --- a/src/Abstractor/Eloquent/Model.php +++ b/src/Abstractor/Eloquent/Model.php @@ -1,23 +1,24 @@ model = $config['model']; @@ -56,6 +63,7 @@ public function __construct( $this->relationFactory = $relationFactory; $this->fieldFactory = $fieldFactory; $this->generator = $generator; + $this->mustDeleteFilesInFilesystem = $mustDeleteFilesInFilesystem; } public function setSlug($slug) @@ -135,10 +143,10 @@ public function getColumns($action, $withForeignKeys = false) } $customDisplayedColumns = $this->getConfigValue($action, 'display'); - $customHiddenColumns = $this->getConfigValue($action, 'hide') ?: []; + $customHiddenColumns = $this->getConfigValue($action, 'hide') ? : []; - $columns = []; - if (!empty($customDisplayedColumns) && is_array($customDisplayedColumns)) { + $columns = array(); + if (! empty($customDisplayedColumns) && is_array($customDisplayedColumns)) { foreach ($customDisplayedColumns as $customColumn) { if (strpos($customColumn, '.')) { $customColumnRelation = explode('.', $customColumn); @@ -153,14 +161,14 @@ public function getColumns($action, $withForeignKeys = false) $relationColumns = $nestedRelation->getModelAbstractor()->getColumns($action); - if (!array_key_exists($customColumnRelationFieldName, $relationColumns)) { - throw new AbstractorException('Column '.$customColumnRelationFieldName.' does not exist on relation '.implode('.', $customColumnRelation).' of model '.$this->getModel()); + if (! array_key_exists($customColumnRelationFieldName, $relationColumns)) { + throw new AbstractorException("Column " . $customColumnRelationFieldName . " does not exist on relation " . implode('.', $customColumnRelation) . " of model " . $this->getModel()); } $columns[$customColumn] = $relationColumns[$customColumnRelationFieldName]; } else { - if (!array_key_exists($customColumn, $tableColumns)) { - throw new AbstractorException('Column '.$customColumn.' does not exist on '.$this->getModel()); + if (! array_key_exists($customColumn, $tableColumns)) { + throw new AbstractorException("Column " . $customColumn . " does not exist on " . $this->getModel()); } $columns[$customColumn] = $tableColumns[$customColumn]; @@ -187,8 +195,8 @@ protected function getNestedRelation(Model $modelAbstractor, $relationName) { $relations = $modelAbstractor->getRelations(); - if (!$relations->has($relationName)) { - throw new AbstractorException('Relation '.$relationName.' not configured on '.$modelAbstractor->getModel()); + if (! $relations->has($relationName)) { + throw new AbstractorException("Relation " . $relationName . " not configured on " . $modelAbstractor->getModel()); } $relation = $relations->get($relationName); @@ -209,7 +217,7 @@ public function getRelations() $relations = collect(); - if (!empty($configRelations)) { + if (! empty($configRelations)) { foreach ($configRelations as $relationName => $configRelation) { if (is_int($relationName)) { $relationName = $configRelation; @@ -217,7 +225,7 @@ public function getRelations() $config = []; if ($configRelation !== $relationName) { - if (!is_array($configRelation)) { + if (! is_array($configRelation)) { $config['type'] = $configRelation; } else { $config = $configRelation; @@ -232,7 +240,7 @@ public function getRelations() $secondaryRelations = $relation->getSecondaryRelations(); - if (!$secondaryRelations->isEmpty()) { + if (! $secondaryRelations->isEmpty()) { $relations->put( $relationName, collect(['relation' => $relation, 'secondaryRelations' => $secondaryRelations]) @@ -248,18 +256,16 @@ public function getRelations() /** * @param string|null $arrayKey - * - * @throws AbstractorException - * * @return array + * @throws AbstractorException */ public function getListFields($arrayKey = 'main') { $columns = $this->getColumns('list'); - $fieldsPresentation = $this->getConfigValue('fields_presentation') ?: []; + $fieldsPresentation = $this->getConfigValue('fields_presentation') ? : []; - $fields = []; + $fields = array(); foreach ($columns as $name => $column) { $presentation = null; if (array_key_exists($name, $fieldsPresentation)) { @@ -271,7 +277,7 @@ public function getListFields($arrayKey = 'main') 'presentation' => $presentation, 'form_type' => null, 'validation' => null, - 'functions' => null, + 'functions' => null ]; $fields[$arrayKey][] = $this->fieldFactory @@ -285,18 +291,16 @@ public function getListFields($arrayKey = 'main') /** * @param string|null $arrayKey - * - * @throws AbstractorException - * * @return array + * @throws AbstractorException */ public function getDetailFields($arrayKey = 'main') { $columns = $this->getColumns('detail'); - $fieldsPresentation = $this->getConfigValue('fields_presentation') ?: []; + $fieldsPresentation = $this->getConfigValue('fields_presentation') ? : []; - $fields = []; + $fields = array(); foreach ($columns as $name => $column) { $presentation = null; if (array_key_exists($name, $fieldsPresentation)) { @@ -308,7 +312,7 @@ public function getDetailFields($arrayKey = 'main') 'presentation' => $presentation, 'form_type' => null, 'validation' => null, - 'functions' => null, + 'functions' => null ]; $fields[$arrayKey][] = $this->fieldFactory @@ -321,12 +325,10 @@ public function getDetailFields($arrayKey = 'main') } /** - * @param bool|null $withForeignKeys + * @param bool|null $withForeignKeys * @param string|null $arrayKey - * - * @throws AbstractorException - * * @return array + * @throws AbstractorException */ public function getEditFields($withForeignKeys = false, $arrayKey = 'main') { @@ -334,9 +336,9 @@ public function getEditFields($withForeignKeys = false, $arrayKey = 'main') $this->readConfig('edit'); - $fields = []; + $fields = array(); foreach ($columns as $name => $column) { - if (!in_array($name, $this->getReadOnlyColumns())) { + if (! in_array($name, $this->getReadOnlyColumns())) { $presentation = null; if (array_key_exists($name, $this->fieldsPresentation)) { $presentation = $this->fieldsPresentation[$name]; @@ -347,7 +349,7 @@ public function getEditFields($withForeignKeys = false, $arrayKey = 'main') 'presentation' => $presentation, 'form_type' => null, 'validation' => null, - 'functions' => null, + 'functions' => null ]; $config = $this->setConfig($config, $name); @@ -357,24 +359,24 @@ public function getEditFields($withForeignKeys = false, $arrayKey = 'main') ->setConfig($config) ->get(); - if (!empty($this->instance) && !empty($this->instance->getAttribute($name))) { + if (! empty($this->instance) && ! empty($this->instance->getAttribute($name))) { $field->setValue($this->instance->getAttribute($name)); } $fields[$arrayKey][$name] = $field; - if (!empty($config['form_type']) && $config['form_type'] === 'file') { + if (! empty($config['form_type']) && $config['form_type'] === 'file') { $field = $this->fieldFactory ->setColumn($column) ->setConfig([ - 'name' => $name.'__delete', + 'name' => $name . '__delete', 'presentation' => null, 'form_type' => 'checkbox', 'no_validate' => true, - 'functions' => null, + 'functions' => null ]) ->get(); - $fields[$arrayKey][$name.'__delete'] = $field; + $fields[$arrayKey][$name . '__delete'] = $field; } } } @@ -384,7 +386,7 @@ public function getEditFields($withForeignKeys = false, $arrayKey = 'main') protected function getReadOnlyColumns() { - $columns = [LaravelModel::CREATED_AT, LaravelModel::UPDATED_AT, 'deleted_at']; + $columns = [LaravelModel::CREATED_AT, LaravelModel::UPDATED_AT]; $columns[] = $this->dbal->getModel()->getKeyName(); @@ -393,7 +395,6 @@ protected function getReadOnlyColumns() /** * @param string $action - * * @return ElementInterface */ public function getForm($action) @@ -406,14 +407,13 @@ public function getForm($action) /** * @param array $requestForm - * * @return mixed */ public function persist(Request $request) { /** @var \ANavallaSuiza\Laravel\Database\Contracts\Manager\ModelManager $modelManager */ $modelManager = App::make('ANavallaSuiza\Laravel\Database\Contracts\Manager\ModelManager'); - if (!empty($this->instance)) { + if (! empty($this->instance)) { $item = $this->instance; } else { $item = $modelManager->getModelInstance($this->getModel()); @@ -425,10 +425,10 @@ public function persist(Request $request) return; } - if (!empty($fields['main'])) { + if (! empty($fields['main'])) { $skip = null; foreach ($fields['main'] as $key => $field) { - /* @var FieldContract $field */ + /** @var FieldContract $field */ if ($skip === $key) { $skip = null; continue; @@ -449,21 +449,21 @@ public function persist(Request $request) } if (get_class($field->getFormField()) === \FormManager\Fields\File::class) { - $handleResult = $this->handleField($request, $item, $fields['main'], 'main', $fieldName); - if (!empty($handleResult['skip'])) { + $handleResult = $this->handleField($request, $item, $fields['main'], 'main', $fieldName,$this->mustDeleteFilesInFilesystem); + if (! empty($handleResult['skip'])) { $skip = $handleResult['skip']; } - if (!empty($handleResult['requestValue'])) { + if (! empty($handleResult['requestValue'])) { $requestValue = $handleResult['requestValue']; } } - if (!$field->saveIfEmpty() && empty($requestValue)) { + if (! $field->saveIfEmpty() && empty($requestValue)) { continue; } - if (!empty($requestValue) || (empty($requestValue) && !empty($item->getAttribute($fieldName)))) { + if (! empty($requestValue) || (empty($requestValue) && ! empty($item->getAttribute($fieldName)))) { $item->setAttribute( $fieldName, $field->applyFunctions($requestValue) @@ -477,12 +477,15 @@ public function persist(Request $request) $this->setInstance($item); - if (!empty($relations = $this->getRelations())) { + if (! empty($relations = $this->getRelations())) { foreach ($relations as $relationKey => $relation) { if ($relation instanceof Collection) { $input = $request->input($relationKey); - $relation->get('relation')->persist($input, $request); + /** @var $relationInstance Relation */ + $relationInstance = $relation->get('relation'); + $relationInstance->persist($input, $request); } else { + /** @var $relation Relation */ $relation->persist($request->input($relationKey), $request); } } @@ -531,7 +534,7 @@ public function getFieldValue($item, $fieldName) } if (empty($relation)) { - return; + return null; } if ($relation instanceof Collection) { @@ -553,4 +556,12 @@ public function getFieldValue($item, $fieldName) return $value; } + + /** + * @return boolean + */ + public function mustDeleteFilesInFilesystem() + { + return $this->mustDeleteFilesInFilesystem; + } } diff --git a/src/Abstractor/Eloquent/ModelFactory.php b/src/Abstractor/Eloquent/ModelFactory.php index ac75100..eb1f3bf 100644 --- a/src/Abstractor/Eloquent/ModelFactory.php +++ b/src/Abstractor/Eloquent/ModelFactory.php @@ -1,14 +1,14 @@ allConfiguredModels = $allConfiguredModels; $this->modelManager = $modelManager; @@ -37,15 +52,14 @@ public function __construct( $this->fieldFactory = $fieldFactory; $this->slugger = new Slugger(); $this->generator = $generator; + $this->anavel = $anavel; } /** * @param $slug * @param null $id - * - * @throws \Exception - * * @return Model|null + * @throws \Exception */ public function getBySlug($slug, $id = null) { @@ -61,7 +75,9 @@ public function getBySlug($slug, $id = null) $modelNamespace = $config; } - $model = new Model($config, $this->modelManager->getAbstractionLayer($modelNamespace), $this->relationFactory, $this->fieldFactory, $this->generator); + $model = new Model($config, $this->modelManager->getAbstractionLayer($modelNamespace), + $this->relationFactory, $this->fieldFactory, $this->generator, + !$this->anavel->hasModule('Anavel\Uploads\UploadsModuleProvider')); $model->setSlug($modelSlug) ->setName($modelName); @@ -78,7 +94,7 @@ public function getBySlug($slug, $id = null) } if (is_null($model)) { - throw new FactoryException('Model '.$slug.' not found on configuration'); + throw new FactoryException("Model ".$slug." not found on configuration"); } return $model; @@ -89,6 +105,7 @@ public function getByName($name, $id = null) return $this->getBySlug($this->slugger->slugify($name)); } + public function getByClassName($classname, array $config, $id = null) { $model = new Model(array_merge(['model' => $classname], $config), $this->modelManager->getAbstractionLayer($classname), $this->relationFactory, $this->fieldFactory, $this->generator); diff --git a/src/Abstractor/Eloquent/Relation/MiniCrud.php b/src/Abstractor/Eloquent/Relation/MiniCrud.php index ab399f8..1b9531a 100644 --- a/src/Abstractor/Eloquent/Relation/MiniCrud.php +++ b/src/Abstractor/Eloquent/Relation/MiniCrud.php @@ -1,11 +1,11 @@ results)) { return $this->results = $this->eloquentRelation->getResults(); } - return $this->results; } @@ -116,16 +115,16 @@ public function getEditFieldsBase() $this->readConfig('edit'); if (!empty($columns)) { - $readOnly = [Model::CREATED_AT, Model::UPDATED_AT, 'deleted_at']; + $readOnly = [Model::CREATED_AT, Model::UPDATED_AT]; //Add field for model deletion $config = [ - 'name' => '__delete', + 'name' => '__delete', 'presentation' => 'Delete', - 'form_type' => 'checkbox', - 'no_validate' => true, - 'validation' => null, - 'functions' => null, + 'form_type' => 'checkbox', + 'no_validate' => true, + 'validation' => null, + 'functions' => null ]; /** @var Field $field */ @@ -147,12 +146,12 @@ public function getEditFieldsBase() } $config = [ - 'name' => $columnName, - 'presentation' => $this->name.' '.ucfirst(transcrud($columnName)), - 'form_type' => $formType, - 'no_validate' => true, - 'validation' => null, - 'functions' => null, + 'name' => $columnName, + 'presentation' => $this->name . ' ' . ucfirst(transcrud($columnName)), + 'form_type' => $formType, + 'no_validate' => true, + 'validation' => null, + 'functions' => null ]; $config = $this->setConfig($config, $columnName); @@ -169,15 +168,15 @@ public function getEditFieldsBase() $field = $this->fieldFactory ->setColumn($column) ->setConfig([ - 'name' => $columnName.'__delete', + 'name' => $columnName . '__delete', 'presentation' => null, - 'form_type' => 'checkbox', - 'no_validate' => true, - 'validation' => null, - 'functions' => null, + 'form_type' => 'checkbox', + 'no_validate' => true, + 'validation' => null, + 'functions' => null ]) ->get(); - $fields[$columnName.'__delete'] = $field; + $fields[$columnName . '__delete'] = $field; } } } @@ -187,7 +186,6 @@ public function getEditFieldsBase() /** * @param array|null $relationArray - * * @return mixed */ public function persist(array $relationArray = null, Request $request) @@ -222,12 +220,13 @@ public function persist(array $relationArray = null, Request $request) $fieldName = $field->getName(); if (get_class($field->getFormField()) === \FormManager\Fields\File::class) { - $handleResult = $this->handleField($request, $relationModel, $fieldsBase, $this->name.".$relationIndex", $fieldName); - if (!empty($handleResult['skip'])) { + $handleResult = $this->handleField($request, $relationModel, $fieldsBase, + $this->name . ".$relationIndex", $fieldName, $this->modelAbstractor->mustDeleteFilesInFilesystem()); + if (! empty($handleResult['skip'])) { $skip = $handleResult['skip']; unset($relationArray[$relationIndex][$skip]); } - if (!empty($handleResult['requestValue'])) { + if (! empty($handleResult['requestValue'])) { $relationArray[$relationIndex][$fieldName] = $handleResult['requestValue']; } } @@ -307,7 +306,6 @@ public function getDisplayType() /** * @param array $fields - * * @return array */ public function addSecondaryRelationFields(array $fields) @@ -320,7 +318,7 @@ public function addSecondaryRelationFields(array $fields) } else { $tempFields[$editGroupName] = $editGroup; } - } + }; } foreach ($fields[$this->name] as $groupKey => $mainFields) { $combinedFields = array_merge($mainFields, $tempFields); diff --git a/src/Abstractor/Eloquent/Traits/HandleFiles.php b/src/Abstractor/Eloquent/Traits/HandleFiles.php index 687f1e4..18eb592 100644 --- a/src/Abstractor/Eloquent/Traits/HandleFiles.php +++ b/src/Abstractor/Eloquent/Traits/HandleFiles.php @@ -1,30 +1,49 @@ slug.DIRECTORY_SEPARATOR; - $basePath = base_path(DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.config('anavel-crud.uploads_path')); - $modelPath = $basePath.$modelFolder; + + + $normalizeGroupName = str_replace('.','#',$groupName); + $contentFromUploadedField="uploaded-content.{$normalizeGroupName}#{$fieldName}#"; + $modelFolder = $this->slug . DIRECTORY_SEPARATOR; + $basePath = base_path(DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR .config('anavel-crud.uploads_path')); + $modelPath = $basePath . $modelFolder; $skip = null; $requestValue = null; - if (!empty($fields["{$fieldName}__delete"])) { + + + if (! empty($fields["{$fieldName}__delete"])) { //We never want to save this field, it doesn't exist in the DB $skip = "{$fieldName}__delete"; //If user wants to delete the existing file - if (!empty($request->input("{$groupName}.{$fieldName}__delete"))) { + if (! empty($request->input("{$groupName}.{$fieldName}__delete"))) { $adapter = new Local($basePath); $filesystem = new Filesystem($adapter); - if ($filesystem->has($item->$fieldName)) { + if ($filesystem->has($item->$fieldName) && $mustDeleteFilesInFilesystem) { $filesystem->delete($item->$fieldName); } @@ -33,40 +52,44 @@ protected function handleField(Request $request, $item, array $fields, $groupNam $fieldName, null ); - return [ - 'skip' => $skip, + 'skip' => $skip ]; } } - if ($request->hasFile($groupName.'.'.$fieldName)) { - $fileName = pathinfo($request->file($groupName.'.'.$fieldName)->getClientOriginalName(), PATHINFO_FILENAME); - $extension = pathinfo($request->file($groupName.'.'.$fieldName)->getClientOriginalName(), PATHINFO_EXTENSION); - $fileName = uniqid().'_'.slugify($fileName); - if (!empty($extension)) { - $fileName .= '.'.$extension; + if($request->has($contentFromUploadedField)) + { + $requestValue = $request->input($contentFromUploadedField); + + }elseif ($request->hasFile($groupName .'.'.$fieldName)) { + $fileName = pathinfo($request->file($groupName .'.'.$fieldName)->getClientOriginalName(), PATHINFO_FILENAME); + $extension = pathinfo($request->file($groupName .'.'.$fieldName)->getClientOriginalName(), PATHINFO_EXTENSION); + + $fileName = uniqid() . '_' . slugify($fileName); + if (! empty($extension)) { + $fileName .= '.' . $extension; } - $request->file($groupName.'.'.$fieldName)->move( + $request->file($groupName .'.'.$fieldName)->move( $modelPath, $fileName ); - $requestValue = $modelFolder.$fileName; - } elseif (!empty($request->file($groupName.'.'.$fieldName)) && !$request->file($groupName.'.'.$fieldName)->isValid()) { - throw new \Exception($request->file($groupName.'.'.$fieldName)->getErrorMessage()); + $requestValue = $modelFolder . $fileName; + } elseif (! empty($request->file($groupName .'.'.$fieldName)) && ! $request->file($groupName .'.'.$fieldName)->isValid()) { + throw new \Exception($request->file($groupName .'.'.$fieldName)->getErrorMessage()); } //Avoid losing the existing filename if the user doesn't change it: - if (empty($requestValue) && (!empty($item->$fieldName))) { + if (empty($requestValue) && (! empty($item->$fieldName))) { $requestValue = $item->$fieldName; } return [ 'requestValue' => $requestValue, - 'skip' => $skip, + 'skip' => $skip ]; } } diff --git a/src/Contracts/Abstractor/Model.php b/src/Contracts/Abstractor/Model.php index 0dfda0c..f7ead13 100644 --- a/src/Contracts/Abstractor/Model.php +++ b/src/Contracts/Abstractor/Model.php @@ -81,4 +81,9 @@ public function getValidationRules(); * @return array */ public function getColumns($action, $withForeignKeys = false); + + /** + * @return bool + */ + public function mustDeleteFilesInFilesystem(); } diff --git a/src/CrudModuleProvider.php b/src/CrudModuleProvider.php index d66e45a..0b2f2eb 100644 --- a/src/CrudModuleProvider.php +++ b/src/CrudModuleProvider.php @@ -71,7 +71,8 @@ function () { $this->app['ANavallaSuiza\Laravel\Database\Contracts\Manager\ModelManager'], $this->app['Anavel\Crud\Contracts\Abstractor\RelationFactory'], $this->app['Anavel\Crud\Contracts\Abstractor\FieldFactory'], - $this->app['Anavel\Crud\Contracts\Form\Generator'] + $this->app['Anavel\Crud\Contracts\Form\Generator'], + $this->app['Anavel\Foundation\Contracts\Anavel'] ); } ); diff --git a/src/Providers/ViewComposersServiceProvider.php b/src/Providers/ViewComposersServiceProvider.php index f82d097..728a756 100644 --- a/src/Providers/ViewComposersServiceProvider.php +++ b/src/Providers/ViewComposersServiceProvider.php @@ -23,5 +23,6 @@ public function boot() public function register() { $this->app->view->composer('anavel-crud::molecules.sidebar.default', 'Anavel\Crud\View\Composers\SidebarComposer'); + $this->app->view->composer('anavel-crud::atoms.forms.field', 'Anavel\Crud\View\Composers\FormFieldComposer'); } } diff --git a/src/View/Composers/FormFieldComposer.php b/src/View/Composers/FormFieldComposer.php new file mode 100644 index 0000000..6659924 --- /dev/null +++ b/src/View/Composers/FormFieldComposer.php @@ -0,0 +1,28 @@ +anavel = $anavel; + } + + public function compose($view) + { + $uploadsModuleIsInstalled = $this->anavel->hasModule('Anavel\Uploads\UploadsModuleProvider'); + + $view->with([ + 'canTakeFileFromUploads' => $uploadsModuleIsInstalled + ]); + } +} \ No newline at end of file diff --git a/tests/Abstractor/Eloquent/ModelFactoryTest.php b/tests/Abstractor/Eloquent/ModelFactoryTest.php index 7d7cf3e..cc9a506 100644 --- a/tests/Abstractor/Eloquent/ModelFactoryTest.php +++ b/tests/Abstractor/Eloquent/ModelFactoryTest.php @@ -19,6 +19,8 @@ class ModelFactoryTest extends TestBase protected $fieldMock; /** @var Mock */ protected $generatorMock; + /** @var Mock */ + protected $anavelMock; public function setUp() { @@ -30,8 +32,9 @@ public function setUp() $this->relationMock = $this->mock('Anavel\Crud\Contracts\Abstractor\RelationFactory'); $this->fieldMock = $this->mock('Anavel\Crud\Contracts\Abstractor\FieldFactory'); $this->generatorMock = $this->mock('Anavel\Crud\Contracts\Form\Generator'); - - $this->sut = new ModelFactory($config, $this->modelManagerMock, $this->relationMock, $this->fieldMock, $this->generatorMock); + $this->anavelMock = $this->mock('Anavel\Foundation\Contracts\Anavel'); + $this->anavelMock->shouldReceive('hasModule')->andReturn(false); + $this->sut = new ModelFactory($config, $this->modelManagerMock, $this->relationMock, $this->fieldMock, $this->generatorMock, $this->anavelMock); } public function test_implements_model__factory_interface() diff --git a/tests/TestBase.php b/tests/TestBase.php index 9815302..f27c51b 100644 --- a/tests/TestBase.php +++ b/tests/TestBase.php @@ -36,7 +36,10 @@ protected function getEnvironmentSetUp($app) 'prefix' => '', ]); + $app['aliases'] = ['Route' => \Illuminate\Support\Facades\Route::class]; + $app['config']->set('anavel.translation_languages', ['gl', 'en', 'es']); + $app['config']->set('anavel-crud.models', []); \App::bind('ANavallaSuiza\Laravel\Database\Contracts\Manager\ModelManager', function ($app) { return \Mockery::mock('ANavallaSuiza\Laravel\Database\Manager\Eloquent\ModelManager'); diff --git a/views/atoms/forms/field.blade.php b/views/atoms/forms/field.blade.php index 2e5b938..5f3b52d 100644 --- a/views/atoms/forms/field.blade.php +++ b/views/atoms/forms/field.blade.php @@ -24,22 +24,41 @@ @endif @else -
+ +
@if($field->attr('type') != 'hidden') +
+ class="control-label">{{ $field->label->html() }}{{ $field->attr('required') ? ' *' : '' }} +
@endif + @if($field instanceof FormManager\Fields\File) +
+ {!! $field->input !!} +
+
-
- {!! $field->input !!} -
+ + @if ($canTakeFileFromUploads) + + {{_('Get from uploads')}} + - @if($field instanceof FormManager\Fields\File && ! empty($field->val())) + @endif + @if (!empty($field->val())) + + Ver + + @endif + +
+ @else +
+ {!! $field->input !!} +
- + @endif - @endif
-@endif \ No newline at end of file +@endif + diff --git a/views/molecules/forms/edit-main.blade.php b/views/molecules/forms/edit-main.blade.php index 5b866b8..57b6ba9 100644 --- a/views/molecules/forms/edit-main.blade.php +++ b/views/molecules/forms/edit-main.blade.php @@ -13,7 +13,7 @@ @empty @endforelse -
+
@unless(empty($form['main'])) @foreach($form['main'] as $field) @@ -59,4 +59,82 @@ @endif @empty @endforelse -
\ No newline at end of file +
+ + + +@section('footer-scripts') + @parent + + +@stop