'boolean', ]; public static function description() { return __eva('Offers let you sell menus, extras and experiences when a customer books a table.'); } public function restaurant() { return $this->belongsTo(Restaurant::class); } public function fields() { return [ [ 'attribute' => 'enabled', 'stacked' => true, 'style' => 'display: inline-block; width: 20%; vertical-align: top;', 'name' => __eva('Enabled'), 'component' => 'boolean-field', 'type' => 'switch', 'value' => $this->enabled, ], [ 'attribute' => 'name', 'stacked' => true, 'inputClass' => 'form-input-bordered-highlight', 'name' => __eva('Name'), 'helpText' => __eva('Internal name to identify this offer'), 'component' => 'text-field', 'value' => $this->name, ], [ 'attribute' => 'notes', 'stacked' => true, 'name' => __eva('Description'), 'helpText' => __eva('Internal description, not shown to customers'), 'component' => 'textarea-field', 'value' => $this->notes, ], [ 'attribute' => 'sections', 'stacked' => true, 'name' => __eva('Builder'), 'component' => 'offer-builder-field', 'value' => $this->valueForSections(), ], ]; } public function defaultValue() { return [ 'name' => __eva('New offer'), 'notes' => '', 'enabled' => true, 'sections' => [], ]; } protected function valueForSections() { $value = $this->sections; if (is_string($value) && $value !== '') { $decoded = json_decode($value, true); if (is_array($decoded)) return $decoded; } if (is_array($value)) return $value; return []; } }