@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** |
| 126 | - * @return mixed |
|
| 126 | + * @return string |
|
| 127 | 127 | */ |
| 128 | 128 | public function getValue() |
| 129 | 129 | { |
@@ -162,6 +162,7 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | /** |
| 164 | 164 | * |
| 165 | + * @param boolean $value |
|
| 165 | 166 | */ |
| 166 | 167 | public function hideValue($value = null) |
| 167 | 168 | { |
@@ -174,6 +175,7 @@ discard block |
||
| 174 | 175 | |
| 175 | 176 | /** |
| 176 | 177 | * |
| 178 | + * @param boolean $value |
|
| 177 | 179 | */ |
| 178 | 180 | public function saveIfEmpty($value = null) |
| 179 | 181 | { |
@@ -186,6 +188,7 @@ discard block |
||
| 186 | 188 | |
| 187 | 189 | /** |
| 188 | 190 | * |
| 191 | + * @param boolean $value |
|
| 189 | 192 | */ |
| 190 | 193 | public function noValidate($value = null) |
| 191 | 194 | { |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | |
| 107 | 107 | public function setFunctions($functions) |
| 108 | 108 | { |
| 109 | - if (! is_array($functions)) { |
|
| 109 | + if (!is_array($functions)) { |
|
| 110 | 110 | $functions = array($functions); |
| 111 | 111 | } |
| 112 | 112 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | public function applyFunctions($value) |
| 117 | 117 | { |
| 118 | 118 | foreach ($this->functions as $function) { |
| 119 | - if (! function_exists($function)) { |
|
| 119 | + if (!function_exists($function)) { |
|
| 120 | 120 | throw new \Exception("Function ".$function." does not exist"); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | { |
| 135 | 135 | $this->value = $value; |
| 136 | 136 | |
| 137 | - if (! $this->hideValue()) { |
|
| 137 | + if (!$this->hideValue()) { |
|
| 138 | 138 | $this->formField->val($this->value); |
| 139 | 139 | } |
| 140 | 140 | } |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | public function getFormField() |
| 170 | 170 | { |
| 171 | - if (! $this->hideValue()) { |
|
| 171 | + if (!$this->hideValue()) { |
|
| 172 | 172 | if (Request::old($this->name)) { |
| 173 | 173 | $this->formField->val(Request::old($this->name)); |
| 174 | 174 | } |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | */ |
| 183 | 183 | public function hideValue($value = null) |
| 184 | 184 | { |
| 185 | - if (! is_null($value)) { |
|
| 185 | + if (!is_null($value)) { |
|
| 186 | 186 | $this->hideValue = $value; |
| 187 | 187 | } |
| 188 | 188 | |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | */ |
| 195 | 195 | public function saveIfEmpty($value = null) |
| 196 | 196 | { |
| 197 | - if (! is_null($value)) { |
|
| 197 | + if (!is_null($value)) { |
|
| 198 | 198 | $this->saveIfEmpty = $value; |
| 199 | 199 | } |
| 200 | 200 | |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | */ |
| 207 | 207 | public function noValidate($value = null) |
| 208 | 208 | { |
| 209 | - if (! is_null($value)) { |
|
| 209 | + if (!is_null($value)) { |
|
| 210 | 210 | $this->noValidate = $value; |
| 211 | 211 | } |
| 212 | 212 | |
@@ -38,9 +38,9 @@ |
||
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | - * @param $slug |
|
| 41 | + * @param string $slug |
|
| 42 | 42 | * @param null $id |
| 43 | - * @return Model|null |
|
| 43 | + * @return Model |
|
| 44 | 44 | * @throws \Exception |
| 45 | 45 | */ |
| 46 | 46 | public function getBySlug($slug, $id = null) |
@@ -3,10 +3,8 @@ |
||
| 3 | 3 | |
| 4 | 4 | use Anavel\Crud\Abstractor\Eloquent\Relation\Traits\CheckRelationCompatibility; |
| 5 | 5 | use Anavel\Crud\Contracts\Abstractor\Field; |
| 6 | -use App; |
|
| 7 | 6 | use Illuminate\Database\Eloquent\Model; |
| 8 | 7 | use Illuminate\Http\Request; |
| 9 | -use Illuminate\Support\Collection; |
|
| 10 | 8 | |
| 11 | 9 | class MiniCrudSingle extends Relation |
| 12 | 10 | { |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | $this->readConfig('edit'); |
| 50 | 50 | |
| 51 | - if (! empty($columns)) { |
|
| 51 | + if (!empty($columns)) { |
|
| 52 | 52 | //Add field for model deletion |
| 53 | 53 | $config = [ |
| 54 | 54 | 'name' => '__delete', |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | $config = [ |
| 76 | 76 | 'name' => $columnName, |
| 77 | - 'presentation' => $this->name . ' ' . ucfirst(transcrud($columnName)), |
|
| 77 | + 'presentation' => $this->name.' '.ucfirst(transcrud($columnName)), |
|
| 78 | 78 | 'form_type' => $formType, |
| 79 | 79 | 'no_validate' => true, |
| 80 | 80 | 'validation' => null, |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | ->setConfig($config) |
| 90 | 90 | ->get(); |
| 91 | 91 | |
| 92 | - if (! empty($result->id)) { |
|
| 92 | + if (!empty($result->id)) { |
|
| 93 | 93 | $field->setValue($result->getAttribute($columnName)); |
| 94 | 94 | } |
| 95 | 95 | |
@@ -109,9 +109,9 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | public function persist(array $relationArray = null, Request $request) |
| 111 | 111 | { |
| 112 | - if (! empty($relationArray)) { |
|
| 112 | + if (!empty($relationArray)) { |
|
| 113 | 113 | $currentRelation = $this->eloquentRelation->getResults(); |
| 114 | - if (! empty($currentRelation)) { |
|
| 114 | + if (!empty($currentRelation)) { |
|
| 115 | 115 | $relationModel = $currentRelation; |
| 116 | 116 | } else { |
| 117 | 117 | $relationModel = $this->eloquentRelation->getRelated()->newInstance(); |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | $relationModel->setAttribute($fieldKey, $fieldValue); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - if (! $shouldBeSkipped) { |
|
| 136 | + if (!$shouldBeSkipped) { |
|
| 137 | 137 | $relationModel->save(); |
| 138 | 138 | } |
| 139 | 139 | } |
@@ -2,9 +2,7 @@ |
||
| 2 | 2 | namespace Anavel\Crud\Abstractor\Eloquent\Relation; |
| 3 | 3 | |
| 4 | 4 | use Anavel\Crud\Abstractor\Eloquent\Relation\Traits\CheckRelationCompatibility; |
| 5 | -use Anavel\Crud\Abstractor\Eloquent\Relation\Traits\CheckRelationConfig; |
|
| 6 | 5 | use Anavel\Crud\Repository\Criteria\InArrayCriteria; |
| 7 | -use App; |
|
| 8 | 6 | use Doctrine\DBAL\Schema\Column; |
| 9 | 7 | use Illuminate\Http\Request; |
| 10 | 8 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | public function persist(array $relationArray = null) |
| 30 | 30 | { |
| 31 | - if (! empty($relationArray)) { |
|
| 31 | + if (!empty($relationArray)) { |
|
| 32 | 32 | /** @var \ANavallaSuiza\Laravel\Database\Contracts\Repository\Repository $repo */ |
| 33 | 33 | $repo = $this->modelManager->getRepository(get_class($this->eloquentRelation->getRelated())); |
| 34 | 34 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | $alreadyAssociated = $this->relatedModel->$relationName; |
| 38 | 38 | |
| 39 | 39 | $search = []; |
| 40 | - if (! empty($relationArray[$relatedKeyName])) { |
|
| 40 | + if (!empty($relationArray[$relatedKeyName])) { |
|
| 41 | 41 | $search = $relationArray[$relatedKeyName]; |
| 42 | 42 | } |
| 43 | 43 | $results = $repo->pushCriteria( |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $result->save(); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - if (! $missing->isEmpty()) { |
|
| 56 | + if (!$missing->isEmpty()) { |
|
| 57 | 57 | foreach ($missing as $result) { |
| 58 | 58 | $result->$keyName = null; |
| 59 | 59 | $result->save(); |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | { |
| 99 | 99 | $results = $this->eloquentRelation->getResults(); |
| 100 | 100 | |
| 101 | - if (! $results->isEmpty()) { |
|
| 101 | + if (!$results->isEmpty()) { |
|
| 102 | 102 | $values = []; |
| 103 | 103 | |
| 104 | 104 | foreach ($results as $result) { |
@@ -3,7 +3,6 @@ |
||
| 3 | 3 | |
| 4 | 4 | use Anavel\Crud\Abstractor\Eloquent\Relation\Traits\CheckRelationCompatibility; |
| 5 | 5 | use Anavel\Crud\Contracts\Abstractor\Field; |
| 6 | -use App; |
|
| 7 | 6 | use Illuminate\Http\Request; |
| 8 | 7 | |
| 9 | 8 | class Translation extends Relation |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $translationFields = []; |
| 49 | - if (! empty($columns)) { |
|
| 49 | + if (!empty($columns)) { |
|
| 50 | 50 | foreach ($this->langs as $key => $lang) { |
| 51 | 51 | $tempFields = []; |
| 52 | 52 | foreach ($columns as $columnName => $column) { |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | $config = [ |
| 68 | 68 | 'name' => $columnName, |
| 69 | - 'presentation' => ucfirst(transcrud($columnName)) . ' [' . $lang . ']', |
|
| 69 | + 'presentation' => ucfirst(transcrud($columnName)).' ['.$lang.']', |
|
| 70 | 70 | 'form_type' => $formType, |
| 71 | 71 | 'no_validate' => true, |
| 72 | 72 | 'validation' => null, |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | public function persist(array $relationArray = null, Request $request) |
| 108 | 108 | { |
| 109 | - if (! empty($relationArray)) { |
|
| 109 | + if (!empty($relationArray)) { |
|
| 110 | 110 | $currentTranslations = $this->eloquentRelation->getResults(); |
| 111 | 111 | $currentTranslations = $currentTranslations->keyBy('locale'); |
| 112 | 112 | |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | { |
| 6 | 6 | public function getConfigValue() |
| 7 | 7 | { |
| 8 | - if (! property_exists($this, 'config') || ! is_array($this->config) || empty($this->config)) { |
|
| 8 | + if (!property_exists($this, 'config') || !is_array($this->config) || empty($this->config)) { |
|
| 9 | 9 | return null; |
| 10 | 10 | } |
| 11 | 11 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | if (is_array($params) && count($params) > 0) { |
| 19 | 19 | foreach ($params as $configKey) { |
| 20 | - if (! array_key_exists($configKey, $nestedConfig)) { |
|
| 20 | + if (!array_key_exists($configKey, $nestedConfig)) { |
|
| 21 | 21 | $nestedConfig = array(); |
| 22 | 22 | return null; |
| 23 | 23 | } |
@@ -80,15 +80,15 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | $field = new Field($this->column, $formElement, $this->config['name'], $this->config['presentation']); |
| 82 | 82 | |
| 83 | - if (! empty($this->config['validation'])) { |
|
| 83 | + if (!empty($this->config['validation'])) { |
|
| 84 | 84 | $field->setValidationRules($this->config['validation']); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - if (! empty($this->config['functions'])) { |
|
| 87 | + if (!empty($this->config['functions'])) { |
|
| 88 | 88 | $field->setFunctions($this->config['functions']); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - if (! empty($this->config['no_validate']) && $this->config['no_validate'] === true) { |
|
| 91 | + if (!empty($this->config['no_validate']) && $this->config['no_validate'] === true) { |
|
| 92 | 92 | $field->noValidate(true); |
| 93 | 93 | } |
| 94 | 94 | |
@@ -113,15 +113,15 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | protected function getFormElement() |
| 115 | 115 | { |
| 116 | - if (! empty($this->config['form_type'])) { |
|
| 117 | - if (! in_array($this->config['form_type'], $this->databaseTypeToFormType)) { |
|
| 118 | - throw new FactoryException("Unknown form type " . $this->config['form_type']); |
|
| 116 | + if (!empty($this->config['form_type'])) { |
|
| 117 | + if (!in_array($this->config['form_type'], $this->databaseTypeToFormType)) { |
|
| 118 | + throw new FactoryException("Unknown form type ".$this->config['form_type']); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | $formElementType = $this->config['form_type']; |
| 122 | 122 | } else { |
| 123 | - if (! array_key_exists($this->column->getType()->getName(), $this->databaseTypeToFormType)) { |
|
| 124 | - throw new FactoryException("No form type found for database type " . $this->column->getType()->getName()); |
|
| 123 | + if (!array_key_exists($this->column->getType()->getName(), $this->databaseTypeToFormType)) { |
|
| 124 | + throw new FactoryException("No form type found for database type ".$this->column->getType()->getName()); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | $formElementType = $this->databaseTypeToFormType[$this->column->getType()->getName()]; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | $formElement = $this->factory->get($formElementType, []); |
| 136 | 136 | |
| 137 | - if (! empty($this->config['attr']) && is_array($this->config['attr'])) { |
|
| 137 | + if (!empty($this->config['attr']) && is_array($this->config['attr'])) { |
|
| 138 | 138 | $formElement->attr($this->config['attr']); |
| 139 | 139 | } |
| 140 | 140 | |
@@ -145,11 +145,11 @@ discard block |
||
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | if ($formElementType === 'textarea') { |
| 148 | - $formElement->class('form-control ' . config('anavel-crud.text_editor')); |
|
| 148 | + $formElement->class('form-control '.config('anavel-crud.text_editor')); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | if (isset($this->config['defaults'])) { |
| 152 | - if (! is_array($this->config['defaults'])) { |
|
| 152 | + if (!is_array($this->config['defaults'])) { |
|
| 153 | 153 | $formElement->val(transcrud($this->config['defaults'])); |
| 154 | 154 | } else { |
| 155 | 155 | $defaults = []; |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | public function getPresentation() |
| 167 | 167 | { |
| 168 | - return transcrud($this->config['presentation']) ? : ucfirst(str_replace('_', ' ', |
|
| 168 | + return transcrud($this->config['presentation']) ?: ucfirst(str_replace('_', ' ', |
|
| 169 | 169 | transcrud($this->config['name']))); |
| 170 | 170 | } |
| 171 | 171 | } |
@@ -103,7 +103,7 @@ |
||
| 103 | 103 | { |
| 104 | 104 | $results = $this->eloquentRelation->getResults(); |
| 105 | 105 | |
| 106 | - if (! empty($results)) { |
|
| 106 | + if (!empty($results)) { |
|
| 107 | 107 | $field->setValue($results->getKey()); |
| 108 | 108 | } |
| 109 | 109 | return $field; |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | { |
| 9 | 9 | public function checkRelationCompatibility() |
| 10 | 10 | { |
| 11 | - if (! in_array(get_class($this->eloquentRelation), $this->compatibleEloquentRelations)) { |
|
| 11 | + if (!in_array(get_class($this->eloquentRelation), $this->compatibleEloquentRelations)) { |
|
| 12 | 12 | throw new RelationException(get_class($this->eloquentRelation)." eloquent relation is not compatible with ".$this->getType()." type"); |
| 13 | 13 | } |
| 14 | 14 | } |