|
| 1 | +<?php |
| 2 | + |
| 3 | +return [ |
| 4 | + /* |
| 5 | + * The package will use this format when working with dates. If this option |
| 6 | + * is an array, it will try to convert from the first format that works, |
| 7 | + * and will serialize dates using the first format from the array. |
| 8 | + */ |
| 9 | + 'date_format' => DATE_ATOM, |
| 10 | + |
| 11 | + /* |
| 12 | + * When transforming or casting dates, the following timezone will be used to |
| 13 | + * convert the date to the correct timezone. If set to null no timezone will |
| 14 | + * be passed. |
| 15 | + */ |
| 16 | + 'date_timezone' => null, |
| 17 | + |
| 18 | + /* |
| 19 | + * It is possible to enable certain features of the package, these would otherwise |
| 20 | + * be breaking changes, and thus they are disabled by default. In the next major |
| 21 | + * version of the package, these features will be enabled by default. |
| 22 | + */ |
| 23 | + 'features' => [ |
| 24 | + 'cast_and_transform_iterables' => false, |
| 25 | + |
| 26 | + /* |
| 27 | + * When trying to set a computed property value, the package will throw an exception. |
| 28 | + * You can disable this behaviour by setting this option to true, which will then just |
| 29 | + * ignore the value being passed into the computed property and recalculate it. |
| 30 | + */ |
| 31 | + 'ignore_exception_when_trying_to_set_computed_property_value' => false, |
| 32 | + ], |
| 33 | + |
| 34 | + /* |
| 35 | + * Global transformers will take complex types and transform them into simple |
| 36 | + * types. |
| 37 | + */ |
| 38 | + 'transformers' => [ |
| 39 | + DateTimeInterface::class => \Spatie\LaravelData\Transformers\DateTimeInterfaceTransformer::class, |
| 40 | + \Illuminate\Contracts\Support\Arrayable::class => \Spatie\LaravelData\Transformers\ArrayableTransformer::class, |
| 41 | + BackedEnum::class => Spatie\LaravelData\Transformers\EnumTransformer::class, |
| 42 | + ], |
| 43 | + |
| 44 | + /* |
| 45 | + * Global casts will cast values into complex types when creating a data |
| 46 | + * object from simple types. |
| 47 | + */ |
| 48 | + 'casts' => [ |
| 49 | + DateTimeInterface::class => Spatie\LaravelData\Casts\DateTimeInterfaceCast::class, |
| 50 | + BackedEnum::class => Spatie\LaravelData\Casts\EnumCast::class, |
| 51 | + // Enumerable::class => Spatie\LaravelData\Casts\EnumerableCast::class, |
| 52 | + ], |
| 53 | + |
| 54 | + /* |
| 55 | + * Rule inferrers can be configured here. They will automatically add |
| 56 | + * validation rules to properties of a data object based upon |
| 57 | + * the type of the property. |
| 58 | + */ |
| 59 | + 'rule_inferrers' => [ |
| 60 | + Spatie\LaravelData\RuleInferrers\SometimesRuleInferrer::class, |
| 61 | + Spatie\LaravelData\RuleInferrers\NullableRuleInferrer::class, |
| 62 | + Spatie\LaravelData\RuleInferrers\RequiredRuleInferrer::class, |
| 63 | + Spatie\LaravelData\RuleInferrers\BuiltInTypesRuleInferrer::class, |
| 64 | + Spatie\LaravelData\RuleInferrers\AttributesRuleInferrer::class, |
| 65 | + ], |
| 66 | + |
| 67 | + /* |
| 68 | + * Normalizers return an array representation of the payload, or null if |
| 69 | + * it cannot normalize the payload. The normalizers below are used for |
| 70 | + * every data object, unless overridden in a specific data object class. |
| 71 | + */ |
| 72 | + 'normalizers' => [ |
| 73 | + Spatie\LaravelData\Normalizers\ModelNormalizer::class, |
| 74 | + // Spatie\LaravelData\Normalizers\FormRequestNormalizer::class, |
| 75 | + Spatie\LaravelData\Normalizers\ArrayableNormalizer::class, |
| 76 | + Spatie\LaravelData\Normalizers\ObjectNormalizer::class, |
| 77 | + Spatie\LaravelData\Normalizers\ArrayNormalizer::class, |
| 78 | + Spatie\LaravelData\Normalizers\JsonNormalizer::class, |
| 79 | + ], |
| 80 | + |
| 81 | + /* |
| 82 | + * Data objects can be wrapped into a key like 'data' when used as a resource, |
| 83 | + * this key can be set globally here for all data objects. You can pass in |
| 84 | + * `null` if you want to disable wrapping. |
| 85 | + */ |
| 86 | + 'wrap' => null, |
| 87 | + |
| 88 | + /* |
| 89 | + * Adds a specific caster to the Symphony VarDumper component which hides |
| 90 | + * some properties from data objects and collections when being dumped |
| 91 | + * by `dump` or `dd`. Can be 'enabled', 'disabled' or 'development' |
| 92 | + * which will only enable the caster locally. |
| 93 | + */ |
| 94 | + 'var_dumper_caster_mode' => 'development', |
| 95 | + |
| 96 | + /* |
| 97 | + * It is possible to skip the PHP reflection analysis of data objects |
| 98 | + * when running in production. This will speed up the package. You |
| 99 | + * can configure where data objects are stored and which cache |
| 100 | + * store should be used. |
| 101 | + * |
| 102 | + * Structures are cached forever as they'll become stale when your |
| 103 | + * application is deployed with changes. You can set a duration |
| 104 | + * in seconds if you want the cache to clear after a certain |
| 105 | + * timeframe. |
| 106 | + */ |
| 107 | + 'structure_caching' => [ |
| 108 | + 'enabled' => true, |
| 109 | + 'directories' => [app_path('Data')], |
| 110 | + 'cache' => [ |
| 111 | + 'store' => env('CACHE_STORE', env('CACHE_DRIVER', 'file')), |
| 112 | + 'prefix' => 'laravel-data', |
| 113 | + 'duration' => null, |
| 114 | + ], |
| 115 | + 'reflection_discovery' => [ |
| 116 | + 'enabled' => true, |
| 117 | + 'base_path' => base_path(), |
| 118 | + 'root_namespace' => null, |
| 119 | + ], |
| 120 | + ], |
| 121 | + |
| 122 | + /* |
| 123 | + * A data object can be validated when created using a factory or when calling the from |
| 124 | + * method. By default, only when a request is passed the data is being validated. This |
| 125 | + * behaviour can be changed to always validate or to completely disable validation. |
| 126 | + */ |
| 127 | + 'validation_strategy' => \Spatie\LaravelData\Support\Creation\ValidationStrategy::OnlyRequests->value, |
| 128 | + |
| 129 | + /* |
| 130 | + * A data object can map the names of its properties when transforming (output) or when |
| 131 | + * creating (input). By default, the package will not map any names. You can set a |
| 132 | + * global strategy here, or override it on a specific data object. |
| 133 | + */ |
| 134 | + 'name_mapping_strategy' => [ |
| 135 | + 'input' => null, |
| 136 | + 'output' => null, |
| 137 | + ], |
| 138 | + |
| 139 | + /* |
| 140 | + * When using an invalid include, exclude, only or except partial, the package will |
| 141 | + * throw an exception. You can disable this behaviour by setting this option to true. |
| 142 | + */ |
| 143 | + 'ignore_invalid_partials' => false, |
| 144 | + |
| 145 | + /* |
| 146 | + * When transforming a nested chain of data objects, the package can end up in an infinite |
| 147 | + * loop when including a recursive relationship. The max transformation depth can be |
| 148 | + * set as a safety measure to prevent this from happening. When set to null, the |
| 149 | + * package will not enforce a maximum depth. |
| 150 | + */ |
| 151 | + 'max_transformation_depth' => null, |
| 152 | + |
| 153 | + /* |
| 154 | + * When the maximum transformation depth is reached, the package will throw an exception. |
| 155 | + * You can disable this behaviour by setting this option to true which will return an |
| 156 | + * empty array. |
| 157 | + */ |
| 158 | + 'throw_when_max_transformation_depth_reached' => true, |
| 159 | + |
| 160 | + /* |
| 161 | + * When using the `make:data` command, the package will use these settings to generate |
| 162 | + * the data classes. You can override these settings by passing options to the command. |
| 163 | + */ |
| 164 | + 'commands' => [ |
| 165 | + |
| 166 | + /* |
| 167 | + * Provides default configuration for the `make:data` command. These settings can be overridden with options |
| 168 | + * passed directly to the `make:data` command for generating single Data classes, or if not set they will |
| 169 | + * automatically fall back to these defaults. See `php artisan make:data --help` for more information |
| 170 | + */ |
| 171 | + 'make' => [ |
| 172 | + |
| 173 | + /* |
| 174 | + * The default namespace for generated Data classes. This exists under the application's root namespace, |
| 175 | + * so the default 'Data` will end up as '\App\Data', and generated Data classes will be placed in the |
| 176 | + * app/Data/ folder. Data classes can live anywhere, but this is where `make:data` will put them. |
| 177 | + */ |
| 178 | + 'namespace' => 'Data', |
| 179 | + |
| 180 | + /* |
| 181 | + * This suffix will be appended to all data classes generated by make:data, so that they are less likely |
| 182 | + * to conflict with other related classes, controllers or models with a similar name without resorting |
| 183 | + * to adding an alias for the Data object. Set to a blank string (not null) to disable. |
| 184 | + */ |
| 185 | + 'suffix' => 'Data', |
| 186 | + ], |
| 187 | + ], |
| 188 | + |
| 189 | + /* |
| 190 | + * When using Livewire, the package allows you to enable or disable the synths |
| 191 | + * these synths will automatically handle the data objects and their |
| 192 | + * properties when used in a Livewire component. |
| 193 | + */ |
| 194 | + 'livewire' => [ |
| 195 | + 'enable_synths' => false, |
| 196 | + ], |
| 197 | +]; |
0 commit comments