How to get the registration info?
The user can access a page where appears a list with his next registrations in conferences, that is, registrations in conferences that have not happened yet. For each registration done by the user, if that registration has not yet been paid, that is, the status column of that registration in the registrations table is "I" (incomplete) it appears the link "Pay":
@foreach($nextRegistrations as $nextRegistration)
@if(!empty($nextRegistration->conference || !empty($nextRegistration->conference->start_date)))
<li class="list-group-item">
<h5>{{optional($nextRegistration->conference)->name}}</h5>
@if ($nextRegistration->status === 'I')
<a href="{{route('conferences.showPaymentPage',
['id' => $nextRegistration->conference->id,
'slug' => $nextRegistration->conference->slug,
'regID'=> $nextRegistration->id])}}"
class="btn btn-primary ml-2"> Pay
</a>
@endif
</li>
@endif
@endforeach
When the user clicks in Pay he should be redirected to a payment page like "http://proj.test/conference/2/conference-title/payment/registration/6", where 6 is the registration id that the user wants to pay and "2" is the conference id, so the user is paying a registration concerning the conference with id "2".
In the registration payment page should appear a summary of the registration. For example, if a user did a registration in a conference with 3 tickets/registration types, 1 of the type "general" and 2 of the type "plus", it should appear a summary like:
Title of the conference (ex: Conference test)
Date of the conference
Registration Type Quantity Price Subtotal
general 1 0.00 € 0.00$
plus 2 1.00 € 2.00$
So I have this route for when the user clicks in the Pay button:
Route::get('/conference/{id}/{slug?}/payment/registration/{regID}', [
'uses' => 'PaymentController@showPaymentPage',
'as' =>'conferences.showPaymentPage'
]);
And in the showPaymentPage() I get the registration of the PaymentController I get the registration with "$registration = Registration::find($regID);":
class PaymentController extends Controller
{
public function showPaymentPage($id = "", $slug = "", $regID){
$registration = Registration::find($regID);
}
}
Doubt:
Do you know how from the $registration get the necessary info to show the registration info like in the above summary?
Relevant tables structure for the question:
Registration table:
id, status, conference_id, main_participant_id
Registration Types table:
id, name, price, confernece_id
Conference table:
id, name, date, organizer_id
Participant table:
id, registration_id, registration_type_id, name, surname
Relevant models for the question:
User model:
class User extends Authenticatable
{
public function conferences(){
return $this->hasMany('App\Conference', 'organizer_id');
}
public function registrations(){
return $this->hasMany('App\Registration','main_participant_id');
}
}
Conference model:
class Conference extends Model
{
public function organizer(){
return $this->belongsTo('App\User', 'organizer_id');
}
public function registrationTypes(){
return $this->hasMany('App\RegistrationType', 'conference_id');
}
public function registrations(){
return $this->hasMany('App\Registration', 'conference_id');
}
}
Registration Type model:
class RegistrationType extends Model
{
public function conference(){
return $this->belongsTo('App\Conference');
}
// a registration can have many participants
public function participants(){
return $this->hasMany('App\Participant');
}
}
Registration model:
class Registration extends Model
{
// a registration has one user that do the registration
public function customer(){
return $this->belongsTo(User::class, 'main_participant_id', 'id');
}
// a registration can have many participants
public function participants(){
return $this->hasMany('App\Participant');
}
public function conference(){
return $this->belongsTo('App\Conference');
}
public function payment()
{
return $this->hasOne('App\Payment');
}
}
Participant model:
class Participant extends Model
{
// a participant belongs to a registration
public function registration(){
return $this->belongsTo('App\Registration');
}
public function registration_type(){
return $this->belongsTo('App\RegistrationType');
}
}
Please or to participate in this conversation.