如何整理注册表以正确处理这4个场景?

时间:2018-05-05 00:42:10

标签: php laravel

我在下面有一个注册表格,用于在国会中注册用户。用户只能在大会上注册他,也可以在其他参与者中注册。注册有4种不同的方案。因此,注册表需要处理这4种不同的场景。但它不起作用,只有方案1和2和4工作正常。方案3无法正常工作。

您知道如何获得支持这4种情况的注册表吗?

方案1是:(唯一正常工作的方案)

  • 国会有两种票类型,例如:"票类1和#34;和"票证类型2"
  • 机票类型"机票类型1"有一个或多个自定义问题,例如,"什么是你的手机?"和票类型"票类型2"没有任何关联的自定义问题
  • 会议表中的all_participants列是" 1"这意味着必须收集用户正在注册的每个参与者的信息(姓名和姓氏)
  • 演示这种情况应该如何的图表:

enter image description here

方案2是:

  • 国会有两种票类型,例如:"票类1和#34;和"票证类型2"
  • 票证类型"票证类型t1"和#34;票类2"没有任何关联的自定义问题
  • 所有参与者都是" 1"这意味着收集每个参与者的信息是必要的
  • 演示这种情况应该如何的图表:

enter image description here

方案3是:

  • 国会有两种票类型,例如:"票类1和#34;和"票证类型2"
  • 机票类型"机票类型1"有关联的自定义问题"您的手机是什么?",机票类型"机票类型2"没有任何关联的自定义问题
  • 所有参与者都是" 0"这意味着没有必要收集每个参与者的信息(姓名和姓氏)
  • 用于演示此方案应如何的图表: enter image description here

方案4是:

  • 国会有两种票类型,例如:"票类1和#34;和"票证类型2"
  • 门票类型"门票类型1"和#34;票类2"没有任何关联的自定义问题
  • 所有参与者都是" 0"这意味着没有必要收集每个参与者的信息(姓名和姓氏)
  • 用于演示此方案应如何的图表: enter image description here

上一页中的所选故障单可在变量" $selectedTypes"。

中找到。

我现在在registration.blade.php中注册的表格如下:

<form method="post" id="step1formfree" action="">
    {{csrf_field()}}
    @if (!is_null($allParticipants) && is_int($allParticipants))
        @if($allParticipants == 1)
            <p>Please fill all fields. Your tickets will be send to <b>{{ (\Auth::check()) ? Auth::user()->email : old('email')}}</b>.</p>
        @else
            <p>Is not necessary additional info. Your tickets will be send to <b>{{ (\Auth::check()) ? Auth::user()->email : old('email')}}</b>.</p>
        @endif

        <span id="userData" data-name="{{ auth()->user()->name }}" data-surname="{{ auth()->user()->surname }}"></span>

        @foreach($selectedRtypes as $k => $selectedRtype)
            //{{dd($selectedRtype)}}
            @foreach(range(1,$selectedRtype['quantity']) as $val)
                @if($allParticipants == 1)
                    <h6>Participant - {{$val}} - {{$k}}</h6>
                    <div class="form-check">
                        <input class="form-check-input" type="checkbox" id="fill_auth_info{{ $val }}" data-id="{{ $k }}_{{ $val }}"name="fill_with_auth_info">
                        <label class="form-check-label d-flex align-items-center" for="fill_auth_info{{ $val }}">
                            <span class="mr-auto">Fill with auth user info.</span>
                        </label>
                    </div>
                    <div class="form-group font-size-sm">
                        <label for="name{{ $k }}_{{ $val }}" class="text-gray">Name</label>
                        <input type="text"  id="name{{ $k }}_{{ $val }}" name="participant_name[]" required class="form-control" value="">
                    </div>
                    <div class="form-group font-size-sm">
                        <label for="surname{{ $k }}_{{ $val }}" class="text-gray">Surname</label>
                        <input type="text" id="surname{{ $k }}_{{ $val }}" required class="form-control" name="participant_surname[]" value="">
                    </div>
                    @foreach($selectedRtype['questions'] as $customQuestion)
                        <div class="form-group">
                            <label for="participant_question">{{$customQuestion->question}}</label>
                            <input type="text"
                                   @if($customQuestion->pivot->required == "1") required @endif
                                   class="form-control" name="participant_question[]">
                            <input type="hidden" name="participant_question_required[]"
                                   value="{{ $customQuestion->pivot->required }}">
                            <input type="hidden" value="{{ $customQuestion->id }}" name="participant_question_id[]"/>
                        </div>
                    @endforeach
                @else
                    <input type="hidden" value="foo" name="participant_name[]"/>
                    <input type="hidden" value="bar" name="participant_surname[]"/>
                @endif
                <input type="hidden" name="rtypes[]" value="{{ $selectedRtype['id'] }}"/>
            @endforeach
                    <div class="form-group">
            @if ($allParticipants == 0)
                @foreach($selectedRtype['questions'] as $customQuestion)
                        <label for="participant_question">{{$customQuestion->question}}</label>
                        <input type="text"
                               @if($customQuestion->pivot->required == "1") required @endif
                               class="form-control" name="participant_question[]">
                        <input type="hidden" name="participant_question_required[]"
                               value="{{ $customQuestion->pivot->required }}">
                        <input type="hidden" value="{{ $customQuestion->id }}" name="participant_question_id[]"/>
                    </div>
                @endforeach
            @endif
        @endforeach
    @endif
    <input type="submit" href="#step2"
           id="goToStep2Free" class="btn btn-primary btn float-right next-step" value="Go to step 2"/>
</form>

&#34; {{dd($selectedRtype)}}&#34;如果没有自定义问题并且选择了同一票证类型的2张票证,则显示:

array:6 [▼
  "quantity" => "2"
  "price" => 0
  "subtotal" => 0
  "total" => 0
  "questions" => Collection {#232 ▼
    #items: []
  }
  "id" => 1
]

如果有区域自定义问题显示:

array:6 [▼
  "quantity" => "1"
  "price" => 0
  "subtotal" => 0
  "total" => 0
  "questions" => Collection {#232 ▼
    #items: array:1 [▼
      0 => Question {#233 ▼
        #fillable: array:3 [▶]
        #connection: "mysql"
        #table: null
        #primaryKey: "id"
        #keyType: "int"
        +incrementing: true
        #with: []
        #withCount: []
        #perPage: 15
        +exists: true
        +wasRecentlyCreated: false
        #attributes: array:6 [▶]
        #original: array:9 [▼
          "id" => 1
          "question" => "What is your phone?"
          "type" => "text"
          "congress_id" => 1
          "created_at" => "2018-05-06 12:24:41"
          "updated_at" => "2018-05-06 12:24:41"
          "pivot_registration_type_id" => 1
          "pivot_question_id" => 1
          "pivot_required" => 1
        ]
        #changes: []
        #casts: []
        #dates: []
        #dateFormat: null
        #appends: []
        #dispatchesEvents: []
        #observables: []
        #relations: array:1 [▶]
        #touches: []
        +timestamps: true
        #hidden: []
        #visible: []
        #guarded: array:1 [▶]
      }
    ]
  }
  "id" => 1
]

与问题相关的关系:

1 to many between Congresses and Registrations
1 to many between Congresses and TicketTypes
1 to many between Registrations and Participants
1 to many between TicketTypes and Participants
1 to many between Participants and Answers
1 to many between Questions and Answers
Many to Many between TicketTypes and Questions
1 to many between Congresses and Questions

1 个答案:

答案 0 :(得分:0)

你的问题中没有足够的描述,但我认为这是因为这一行:

<h6>Participant - 1 - {{$test}}</h6>

此行没有条件,将在整个循环中重复 那是因为你牵着走。 我希望它有所帮助。