firefly-iii/app/Repositories/Attachment/AttachmentRepository.php

49 lines
1.1 KiB
PHP
Raw Normal View History

2015-07-19 02:37:28 -05:00
<?php
2016-02-05 05:08:25 -06:00
declare(strict_types = 1);
2015-07-19 02:37:28 -05:00
namespace FireflyIII\Repositories\Attachment;
use FireflyIII\Models\Attachment;
/**
* Class AttachmentRepository
*
* @package FireflyIII\Repositories\Attachment
*/
class AttachmentRepository implements AttachmentRepositoryInterface
{
2015-07-26 08:51:07 -05:00
/**
* @param Attachment $attachment
*
* @return bool
*/
public function destroy(Attachment $attachment)
{
/** @var \FireflyIII\Helpers\Attachments\AttachmentHelperInterface $helper */
$helper = app('FireflyIII\Helpers\Attachments\AttachmentHelperInterface');
$file = $helper->getAttachmentLocation($attachment);
unlink($file);
$attachment->delete();
}
2015-07-19 02:37:28 -05:00
/**
* @param Attachment $attachment
* @param array $data
*
* @return Attachment
*/
public function update(Attachment $attachment, array $data)
{
$attachment->title = $data['title'];
$attachment->description = $data['description'];
$attachment->notes = $data['notes'];
$attachment->save();
return $attachment;
}
2015-07-19 02:38:44 -05:00
}