Display what subscriptions (if any) a subscriber has

This commit is contained in:
James Brooks
2016-02-09 19:09:30 +00:00
committed by Graham Campbell
parent c9f08a3e6e
commit 0b78332a20
4 changed files with 53 additions and 27 deletions
+7
View File
@@ -48,6 +48,13 @@ class Subscriber extends Model implements HasPresenter
'email' => 'required|email',
];
/**
* The relations to eager load on every query.
*
* @var string[]
*/
protected $with = ['subscriptions'];
/**
* Overrides the models boot method.
*/
+11
View File
@@ -14,6 +14,7 @@ namespace CachetHQ\Cachet\Presenters;
use CachetHQ\Cachet\Dates\DateFactory;
use CachetHQ\Cachet\Presenters\Traits\TimestampsTrait;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Support\Facades\Config;
use McCool\LaravelAutoPresenter\BasePresenter;
class SubscriberPresenter extends BasePresenter implements Arrayable
@@ -30,6 +31,16 @@ class SubscriberPresenter extends BasePresenter implements Arrayable
return app(DateFactory::class)->make($this->wrappedObject->verified_at)->toDateTimeString();
}
/**
* Present formatted subscribed date.
*
* @return string
*/
public function subscribed_at()
{
return ucfirst(app(DateFactory::class)->make($this->wrappedObject->subscribed_at)->format(Config::get('setting.incident_date_format', 'l jS F Y H:i:s')));
}
/**
* Convert the presenter instance to an array.
*