private_reference_number = str_pad(rand(0, pow(10, 9) - 1), 9, '0', STR_PAD_LEFT); }); } /** * The order associated with the attendee. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function order() { return $this->belongsTo('\App\Models\Order'); } /** * The ticket associated with the attendee. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function ticket() { return $this->belongsTo('\App\Models\Ticket'); } /** * The event associated with the attendee. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function event() { return $this->belongsTo('\App\Models\Event'); } /** * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function answers() { return $this->hasMany('App\Models\QuestionAnswer'); } /** * Scope a query to return attendees that have not cancelled. * * @param $query * * @return mixed */ public function scopeWithoutCancelled($query) { return $query->where('attendees.is_cancelled', '=', 0); } /** * Get the attendee reference * * @return string */ public function getReferenceAttribute() { return $this->order->order_reference . '-' . $this->reference_index; } /** * Get the full name of the attendee. * * @return string */ public function getFullNameAttribute() { return $this->first_name . ' ' . $this->last_name; } /** * The attributes that should be mutated to dates. * * @var array $dates */ public function getDates() { return ['created_at', 'updated_at', 'arrival_time']; } }