Attendize/app/Models/Attendee.php

67 lines
1.3 KiB
PHP
Raw Normal View History

2016-03-05 00:18:10 +00:00
<?php
namespace App\Models;
2016-02-29 15:59:36 +00:00
use Illuminate\Database\Eloquent\SoftDeletes;
/*
Attendize.com - Event Management & Ticketing
*/
/**
2016-03-05 00:18:10 +00:00
* Description of Attendees.
2016-02-29 15:59:36 +00:00
*
* @author Dave
*/
2016-03-05 00:18:10 +00:00
class Attendee extends MyBaseModel
{
2016-02-29 15:59:36 +00:00
use SoftDeletes;
2016-03-05 00:18:10 +00:00
public function order()
{
2016-02-29 15:59:36 +00:00
return$this->belongsTo('\App\Models\Order');
}
2016-03-05 00:18:10 +00:00
public function ticket()
{
2016-02-29 15:59:36 +00:00
return $this->belongsTo('\App\Models\Ticket');
}
2016-03-05 00:18:10 +00:00
public function event()
{
return $this->belongsTo('\App\Models\Event');
2016-02-29 15:59:36 +00:00
}
2016-03-05 00:18:10 +00:00
public function scopeWithoutCancelled($query)
{
2016-02-29 15:59:36 +00:00
return $query->where('attendees.is_cancelled', '=', 0);
}
2016-03-05 00:18:10 +00:00
public function getFullNameAttribute()
{
2016-02-29 15:59:36 +00:00
return $this->first_name.' '.$this->last_name;
}
2016-03-05 00:18:10 +00:00
//
2016-02-29 15:59:36 +00:00
// public function getReferenceAttribute() {
// return $this->order->order_reference
// }
2016-03-05 00:18:10 +00:00
public function getDates()
{
return ['created_at', 'updated_at', 'arrival_time'];
2016-02-29 15:59:36 +00:00
}
2016-03-05 00:18:10 +00:00
/**
* Generate a private referennce number for the attendee. Use for checking in the attendee.
*/
public static function boot()
{
parent::boot();
static::creating(function ($order) {
$order->private_reference_number = str_pad(rand(0, pow(10, 9) - 1), 9, '0', STR_PAD_LEFT);
2016-02-29 15:59:36 +00:00
});
2016-03-05 00:18:10 +00:00
}
2016-02-29 15:59:36 +00:00
}