mirror of
https://gitlab.com/uldvstar/exchange-2.0.git
synced 2026-08-19 04:24:16 +00:00
30 lines
1.0 KiB
PHP
30 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Notifications\Services;
|
|
|
|
use App\Classes\Modules\Notifications\DataTransferObjects\NotificationObject;
|
|
use App\Models\Notification;
|
|
|
|
class CreatesNotification
|
|
{
|
|
/**
|
|
* @param NotificationObject $object
|
|
* @return \Illuminate\Database\Eloquent\Model
|
|
* @throws \App\Classes\Exceptions\MalformedRequestException
|
|
*/
|
|
public function execute(NotificationObject $object) {
|
|
$model = new Notification();
|
|
$model->title = $object->getTitle();
|
|
$model->description = $object->getDescription();
|
|
$model->status = $object->getStatus();
|
|
$model->subject_type = get_class($object->getSubject());
|
|
$model->subject_id = $object->getSubject()->id;
|
|
$model->target_type = get_class($object->getTarget());
|
|
$model->target_id = $object->getTarget()->id;
|
|
$model->causer_type = get_class($object->getCauser());
|
|
$model->causer_id = $object->getCauser()->id;
|
|
$model->save();
|
|
|
|
return $model;
|
|
}
|
|
} |