0
votes

I have a page "single.blade.php" that shows the details of a congress and also a form for the user select the quantities that he wants for each congress ticket type.

After click "Next" in this form the Registrationcontroller in the storeQuantity method stores the selected quantities and return the registration view and returns to the registration view the $selectedTypes array.

So in the registration page I show some informations of the selected quantities with:

 @foreach($selectedTypes as $k=>$selectedType)
    <li>
        <span>{{$k}}</span>
        <span >{{$selectedType['quantity']}}</span>
        <span>{{ number_format($selectedType['price'], 2)}}$</span>
        <span>{{ number_format($selectedType['subtotal'], 2)}}$</span>
    </li>
@endforeach

Below this code above I want to show the billing information form only if there are paid ticket types in the $selectedTypes array, that is show the billing information form only if the congress has 1 or more paid ticket types.

The Billing Information below has this strucutre:

<h6>Billing Information</h6>
<div>
    <label for="inputName" class="text-gray">Name</label>
    <input type="text" class="form-control" id="inputName">
<div>
<div>
    <label for="inputName" class="text-gray">Country</label>
    <select class="form-control custom-select" id="exampleFormControlSelect1">
        <option selected class="selected"></option>
    </select>
</div>
<button type="button" href="#step2" data-toggle="tab" role="tab">
    Go To Step 2
</button>

Do you know how to show the billing information form only if there are paid ticket types?

TicketType Model:

class TicketType extends Model
{
    protected $fillable = [
        'name', 'price', 'minPerUser', 'maxPerUser','congress_id'
    ];
    public function congress(){
        return $this->belongsTo('App\Congress');
    }
}

Congress Model:

class Congress extends Model
{
    public function ticketTypes(){
        return $this->hasMany('App\TicketType', 'congress_id');
    }
}

Note:

Each congress has one or more ticket types, each ticket type has a column "price" in the database. A congress can be free, but If there is some congress tiket that is paid, that is, the value of the column price is greater than 0 I want to show in the registration page some billing information form, otherwise I dont want to show this form.

1

1 Answers

2
votes

This is a rather broad question, therefore here is my broad answer

I would create a optional billing page that is shown only when one of the tickets has a price of more than $0, if all the selected congress are free then just skip the billing information page and continue the process

I will recomed that you create a BillingInformationModel that is bound one-to-one with the Congress model, since with one registration only one payment can be made regardless of how many congress were selected