return;
} /** @var Media|null $media */
$media =
$this->
get('models'
)->
getRepository(Media::
class)->
find($mediaId);
if (!
$media) { $this->
View()->
assign(['success' => false, 'message' => 'Media not found'
]);
return;
} $attachment =
new Attachment($mail,
$media);
try { $this->
get('models'
)->
persist($attachment);
$this->
get('models'
)->
flush();
} catch (Exception
$e) { $this->
View()->
assign(['success' => false, 'message' =>
$e->
getMessage()]);
return;
} $data =
$this->
get('models'
)->
toArray($attachment);