Subscription blolean can’t be false

Laraship QuestionsCategory: TechnicalSubscription blolean can’t be false
Ezio Baviera asked 4 years ago
If i create a bolean field in features and i not check the relative checkbox during plan creation i can't save. I have this error: The given data was invalid
1 Answers
laraship Staff answered 4 years ago
Hello We just pushed a fix for the issue, please update your subscription module.   Best Regards.
Ezio Baviera replied 4 years ago

i suggest this fix in Corals\modules\Subscriptions\Http\Requests\PlanRequest.php
<pre>foreach ($this->get('features', []) as $id => $feature) {
$featureModel = Feature::find($id);

switch ($featureModel->type) {
case 'text':
case 'config':
$rules = array_merge($rules, [
"features.{$id}.value" => 'required'
]);
break;
case 'quantity':
$rules = array_merge($rules, [
"features.{$id}.value" => 'numeric'
]);
break;
}
}</pre>
and this in pricing view
<pre><ul class="list-unstyled price-features">
@foreach($product->activeFeatures as $feature)
@if($plan_feature = $plan->features()->where('feature_id',$feature->id)->first())
<li>
@if(!empty($plan_feature->pivot->plan_caption))
{{ $plan_feature->pivot->plan_caption }}
@else
@if($feature->type=="boolean")
@if($plan_feature->pivot->value)
<i class="fa fa-check"></i>
@else
<i class="fa fa-times"></i>
@endif
@else
@if($plan_feature->pivot->value != "")
{{$plan_feature->pivot->value }} {{$feature->unit }}
@else
<i class="fa fa-times"></i>
@endif
@endif
{{ $feature->caption }}
@endif
</li>
@else
<li>
<i class="fa fa-times"></i>
{{ $feature->caption }}
</li>
@endif
@endforeach
</ul></pre>

laraship Staff replied 4 years ago

Hello,
What is this for?

Ezio Baviera replied 4 years ago

I create text or number fields but in some plan i need leave empty i can’t save becouse value is required, but whit this fix i can use empty fileds and in frontend i see the cross in the relative feature. I make another fix to manage all corretly and i just finished to test it. If you want i can send you the code.
Look this example https://ibb.co/NFwLWMC