Attendize/app/Models/Message.php

63 lines
1.1 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
2016-09-06 20:39:27 +00:00
/*
Attendize.com - Event Management & Ticketing
*/
2016-02-29 15:59:36 +00:00
/**
2016-03-05 00:18:10 +00:00
* Description of Message.
2016-02-29 15:59:36 +00:00
*
* @author Dave
*/
2016-03-05 00:18:10 +00:00
class Message extends MyBaseModel
{
2016-03-14 16:37:38 +00:00
/**
* The attributes that are mass assignable.
*
* @var array $fillable
*/
protected $fillable = [
'message',
'subject',
'recipients',
];
2016-03-14 16:37:38 +00:00
/**
* The event associated with the message.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
2016-03-05 00:18:10 +00:00
public function event()
{
2016-02-29 15:59:36 +00:00
return $this->belongsTo('\App\Models\Event');
}
2016-03-05 00:18:10 +00:00
2016-03-14 16:37:38 +00:00
/**
* Get the recipient label of the model.
*
* @return string
*/
2016-03-05 00:18:10 +00:00
public function getRecipientsLabelAttribute()
{
if ($this->recipients == 0) {
2016-02-29 15:59:36 +00:00
return 'All Attendees';
}
2016-03-05 00:18:10 +00:00
2016-02-29 15:59:36 +00:00
$ticket = Ticket::scope()->find($this->recipients);
2016-03-05 00:18:10 +00:00
2016-09-06 20:39:27 +00:00
return 'Ticket: ' . $ticket->title;
2016-02-29 15:59:36 +00:00
}
2016-03-14 16:37:38 +00:00
/**
* The attributes that should be mutated to dates.
*
* @var array $dates
*/
2016-03-05 00:18:10 +00:00
public function getDates()
{
return ['created_at', 'updated_at', 'sent_at'];
}
2016-02-29 15:59:36 +00:00
}