How to properly get the information about all registrations in a specific congress?

copyright registration fee
u.s. copyright office login
copyright registration form
list of registered lobbyists federal
when and how do i register a copyright
eco online system
how do i formally register my original, creative work?
copyright standard application

I have a registration form for a user to register in a congress.

For example, if the user John is doing a registration in a congress and a registration with 2 participants (him and his colleague Jake) and John is registering him in ticket type tt1 and Jake in the ticket type tt2 in the database is inserted an entry in the Registrations table to store which user did the registration and in which congress. Then, it is also inserted in the participants table an entry for each registered participant by the user that did the registration (main_participant). So the tables stay like:

registrations table

id | status | congress_id | main_participant_id
---+--------+-------------+--------------------
7  | C      | 1           | 1

participants table

id | registration_id | ticket_type_id | name | surname
---+-----------------+----------------+------+--------
12 | 7               | 1              | John | W
13 | 7               | 2              | Jake | Y

Now I have a ParticipantController that has the index method, that gets the info of a specific Congress:

class ParticipantController extends Controller
{
    public function index($id)
    {
        $congress = Congress::find($id);
        return view('participants.index')->with('congress', $congress);
    }
}

In this participants.index view I want to list in a table the registrations deails:

  1. all users that did a registration in this specific congress;
  2. the quantity of tickets that they acquired;
  3. the ticket types; and
  4. the status of the registration (Complete, Incomplete).

So, is it possible to have a table in the following image?

What is necessary to properly get this information? I'm not understanding how to get this. Both tables in the image above are the same, the only difference is:

  • the first part of the image is when all_participant is 1 in the congresses table, which means in the congress registration form was necessary to collect info (name and surname) of each participant, so the user that did the registration needed to introduce the name and surname of each participant. Then, the name and surname of each participant should appear in the modal, as in the image.
  • in the case when all_participant is 0 in the congresses table the name and surname of each participant are blank (''). That's because in the registration form was not necessary to collect info of each participant.

Related to the Ticket type(s) column in the table: a user can do a registration with multiple participants. For example, John can select 2 ticekts, one of the ticket type tt1 and other of the ticket type tt2. If the registration includes 1 or more ticket types it should appear in the Ticket type(s) column the ticket types associated with that specific registratation, as in the image above for the first registration (for the user John W).

With this code in the ParticipantController:

 $allRegistrations = $congress->registrations()->get();

And then in the view:

@foreach ($allRegistrations as $r)
    {{ $r }}
@endforeach

I got:

{"id":10,"status":"C","congress_id":1,"main_participant_id":1}

The status can be gotten like {{ $r->status }}. But, how to get the other necessary info that is in the image? The quantity, ticket types and the name of the user that did the registration? And the info in the modal: the name and surname of each participant, or show "" if all_participant is 0, and also the ticket type associated to each participant.

To show all registrations and the necessary info as in the image, I don't know if the database structure I have allows to get that information properly. For now, the database looks like this:

Laravel models:

// Congress model
class Congress extends Model
{ 
    // A conference has one creator
    public function creator(){
        return $this->belongsTo('App\User', 'user_id');
    }
    public function ticketTypes(){
        return $this->hasMany('App\TicketType', 'congress_id');
    }
    public function registrations(){
        return $this->hasMany('App\Registration', 'congress_id');
    }
}

// User model
class User extends Authenticatable
{
    public function congresses(){
        return $this->hasMany('App\Congress', 'user_id');
    }

    // A user can register in many conferences
    public function registrations(){
        return $this->hasMany('App\Registration','main_participant_id');
    }
}

// Registration model
class Registration extends Model
{
    // a registration has one user that do the registration
    public function customer(){
        return $this->belongsTo('App\User');
    }

    // a registration can have many participants
    public function participants(){
        return $this->hasMany('App\Participant');
    }

    public function congress(){
        return $this->belongsTo('App\Congress');
    }
}

// Participant Model
class Participant extends Model
{
    // a participant belongs to a registration
    public function registration(){
        return $this->belongsTo('App\Registration');
    }
}

// Ticket Type model
class TicketType extends Model
{
    public function congress(){
        return $this->belongsTo('App\Congress');
    }

    public function questions(){
        return $this->belongsToMany('App\Question', 'ticket_type_questions')->withPivot(['required']);;
    }
}

// Question model
class Question extends Model
{
    public function ticket_type(){
        return $this->belongsToMany('App\TicketType', 'ticket_type_questions')
            ->withPivot('required');
    }
}

// Answer model
class Answer extends Model
{
    public function question(){
        return $this->belongsTo('Question');
    }
    public function participant(){
        return $this->belongsTo('Participant');
    }
}

// TicketTypeQuestion model
class TicketTypeQuestion extends Model
{
}

Finally, a ticket type may have custom questions associated to it. For example, in the image below both ticket types tt1 and tt2 have the custom question "Whats your phone?" associated to them. In that case, the answers to these questions, answered by the use that did the registration, should appear in the modal when the user clicks in the + to see the details. How to get these answers? In this image examples the phone of the participant 1 is 002.. and the phone of the participant 2 is 003...

The answer was updated based on information provided in the comments.

First, you have to fix the relation between Registration and User class. It is using the default column naming, but your schema uses a different one:

class Registration extends Model
{

    // ...

    public function customer()
    {
        return $this->belongsTo('App\User', 'main_participant_id');
    }

    // ...

}

If you have access to do that, I would suggest you to change that column's name to something more clear. The current name takes one to assume it references the participants table.

With that relation fixed, you are now able to get the main participant by calling its magic property. This will return a User model instance:

$registration->customer;

Additionaly, you have to add a relation between participants and ticket types to your Participant class:

class Participant extends Model
{

    // ...

    public function ticketType()
    {
        return $this->belongsTo('App\TicketType');
    }

    // ...

}

This relation will allow you to get the ticket type details, including its name, from any participant model instance.

Then, on the view, you should be able to do the following:

<table>
    <tr>
        @foreach ($congress->registrations as $registration)

            <!-- User that did the registration -->
            <td>{{ $registration->customer->name }}</td>

            <!-- Email.
                 Although, I don't see an email field in your DB schema -->
            <td>{{ $registration->customer->email }}</td>

            <!-- Ticket types -->
            <td>
                {{
                    $registration->participants
                        ->map(function ($participant) {
                            return $participant->ticket_type->name;
                        })
                        ->implode(', ')
                }}
            </td>

            <!-- Quantity -->
            <td>{{ $registration->participants->count() }}</td>

            <!-- Status -->
            <td>{{ $registration->status === 'C' ? 'Confirmed' : 'Waiting' }}</td>

            <!-- Date. Considering a Carbon instance.
                 Although, I don't see a created_at field in your DB schema -->
            <td>{{ $registration->created_at->format('m/d/y') }}</td>

        @endforeach
    </tr>
</table>

As you can see, I used a "trick" to get all the types within a single method chain. That's possible because Eloquent results, except for when a single instance is returned and other special cases, are usually Collections. You can learn more about Eloquent collections and the available methods on the Laravel docs. Also, notice my comments above on missing fields.

Finally, for the second view, you can iterate through all participants of a specific registration:

<!-- User that did the registration -->
<dl>
    <dt>Name</dt>
    <dd>{{ $registration->customer->name }}</dd>
    <dt>Email</dt>
    <dd>{{ $registration->customer->email }}</dd>
</dl>

@foreach ($registration->participants as $participant)

    <!-- Participant N -->
    <dl>
        <dt>Name</dt>
        <dd>{{ $participant->name }}</dd>
        <dt>Surname</dt>
        <dd>{{ $participant->surname }}</dd>
        <dt>Ticket Type</dt>
        <dd>tt{{ $participant->ticket_type_id }}</dd>
    </dl>

@endforeach

House, Senate and presidential candidate registration, An individual running for a seat in the House or Senate or for the office of U.S. President becomes a All such candidates must register with a Statement of Candidacy (Form 2) and designate a It collects some basic information, including the candidate's name and address. Get help from the FEC by phone or email  Home > Federal Register > Federal Register Tutorial: What it Is and How to Use It > Federal Register Tutorial Public Workshops If you work with the Federal Register (FR) or the Code of Federal Regulations (CFR), you may find these free workshops especially valuable.

You should be able to get all the data as follows:

class ParticipantController extends Controller
{
    public function index(Congress $congress) {
        return view('participants.index')->with('congress', $congress->load('registrations.participants');
    }
}

View:

<tr>
    <th>User that did the registration</th>
    <th>Quantity</th>
    <th>Status</th>
</tr>

@foreach($congress->registrations as $registration)
    <tr>
        <td>{{ $registration->participants->where('ticket_type_id', $congress->main_participant_id)->first()->name }}</td>
        <td>{{ $registration->participants->count() }}</td>
        <td>{{ $registration->status === 'C' ? 'Complete' : 'Incomplete' }}</td>
    </tr>
@endforeach

Some of this view logic probably belongs in the model or decorator.

Lobbying Database Reporting Recipe, Our new lobbying database will help you cover Congress and the organizations When lobbying registrations cite a specific bill, our app will link you to that bill. they lobbied and noting any changes to the issues or lobbyists involved. The data from these forms can provide a wealth of information about  The registration is the initial statement of copyright information about a work and indicates the author, date of registration, copyright claimant (at the time of filing the registration), and date of first publication.

If you are asking about MySQL query. This is query to get the information about all registrations in a specific congress?

SELECT * FROM `Registrations` r
INNER JOIN Participants p on p.registration_id = r.id
WHERE congress_id = 1

Guide to the Lobbying Disclosure Act, This document is a compilation of all previously issued guidance documents have the force of law, nor does it have any binding effect on the United States A lobbying firm is exempt from registration for a particular client if its total Thus, if a lobbyist has not been properly terminated/delisted on the Information Update  information, which was necessary for the recovery. If you have knowledge regarding the unauthorized Congress content sharing, contact the Congress registration office. REGISTRATION BINDING AGREEMENT Registration (whether online or by this form) constitutes a contract and all of these terms and conditions are binding on the parties.

Congress.gov, U.S. Congress legislation, Congressional Record debates, Members of Congress​, legislative process educational resources presented by the Library of  Also, in addition to providing all the information THOMAS does, OpenCongress also provides you with letters to Congress about the bill. These letters, written by concerned citizens, either oppose or support the bill and state their reasons why. If you are a registered user, you can even write a letter to Congress voicing your opinion.

Reader Registration and Access to Library of Congress Reading , Notice: Out of an abundance of caution, all Library of Congress research centers will be Library staff will verify your information, take an identification photo, have you Special Instructions for Registering Large Groups All ways to connect  12. I will be able to attend this Congress just for one day. Can I pre-register for that specific date? Yes, you can pre-register by using the online system for one day starting March 28, 2019. You can also register directly at the Hungexpo in Budapest starting from June 12, 2019. 13. Can I send a cheque to pay my Congress membership

Library and Information Science: A Guide to Online Resources , What do the different Library of Congress numbers mean? How do I find a book's Dewey Decimal classification (DDC) number or Dewey call number? How can I search copyright registration and renewal records online? Librarians use it to locate a specific Library of Congress catalog record in union catalogs such as  Registrations will be possible from June 1 st 2019, depending on seat availability. Any person not wearing the Congress Badge will be refused access to all Scientific Session rooms/venues (Plenary/Parallel Sessions, Workshops). For specific needs due to physical disability or any other need, please contact the Congress Secretariat.

Comments
  • Thanks, in the ParticipantController the index() method remains as it is in the question? Like: class ParticipantController extends Controller { public function index($id){ $congress = Congress::find($id); $allRegistrations = $congress->registrations()->get(); return view('participants.index')->with('congress', $congress); } } ?
  • With " <td>{{$registration->mainParticipant->name}}e</td> " it appears "SQLSTATE[42S22]: Column not found: 1054 Unknown column 'participants.participant_id' in 'where clause' (SQL: select * from participants where participants.participant_id = 1 and participants.participant_id is not null limit 1) ".
  • @joW My bad. The right relation is the following: return $this->hasOne('App\Participant', 'id', 'main_participant_id');. I've just updated the answer.
  • Thanks, but now appears "Trying to get property of non-object" in " <td><?php echo e($registration->mainParticipant->name); ?>e</td>".
  • Do you have a record in your participants table for id = 1? If you don't, you may have an inconsistency in your DB.
  • Thanks, only the user that did the registration name is not appearing, it appears like "[]" Do you know why? The main_participant_id is a column of the registrations table, the main_participant_id for example "1" is the id of the user "1" in the users table, which means that was the user with id "1" that did the registartion.
  • For example if the user John that has id "1" in the users table did a registration in the congress in he registrations table the main_participant_id will be "1" because is the id of the user that did the registration.
  • Ok then it becomes easier, just add a relationship for it and use that.
  • Thanks but it appears "Trying to get property of non-object". Maybe is because this "$congress->main_participant_id" appears as null.
  • yeah if main_participant_id is null the lookup will fail, the code assumes that there is one. You can add more checks around using conditionals, or enforce it using validation in previous steps.
  • Thanks, but the question is using larave and eloquent.