Expand API for attachments.

This commit is contained in:
James Cole
2018-06-24 06:51:22 +02:00
parent 32b6ded008
commit ad6a9a7df7
28 changed files with 1290 additions and 59 deletions

View File

@@ -44,6 +44,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property AccountType $accountType
* @property bool $active
* @property string $virtual_balance
* @property User $user
*/
class Account extends Model
{

View File

@@ -22,6 +22,7 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
use Crypt;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Model;
@@ -32,6 +33,20 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Class Attachment.
*
* @property int $id
* @property Carbon $created_at
* @property Carbon $updated_at
* @property string $attachable_type
* @property string $md5
* @property string $filename
* @property string $title
* @property string $description
* @property string $notes
* @property string $mime
* @property int $size
* @property User $user
* @property bool $uploaded
*/
class Attachment extends Model
{
@@ -100,9 +115,9 @@ class Attachment extends Model
* @return null|string
* @throws \Illuminate\Contracts\Encryption\DecryptException
*/
public function getDescriptionAttribute($value)
public function getDescriptionAttribute($value): ?string
{
if (null === $value || 0 === \strlen($value)) {
if (null === $value || '' === $value) {
return null;
}
@@ -116,9 +131,9 @@ class Attachment extends Model
* @return null|string
* @throws \Illuminate\Contracts\Encryption\DecryptException
*/
public function getFilenameAttribute($value)
public function getFilenameAttribute($value): ?string
{
if (null === $value || 0 === \strlen($value)) {
if (null === $value || '' === $value) {
return null;
}
@@ -132,9 +147,9 @@ class Attachment extends Model
* @return null|string
* @throws \Illuminate\Contracts\Encryption\DecryptException
*/
public function getMimeAttribute($value)
public function getMimeAttribute($value): ?string
{
if (null === $value || 0 === \strlen($value)) {
if (null === $value || '' === $value) {
return null;
}
@@ -148,9 +163,9 @@ class Attachment extends Model
* @return null|string
* @throws \Illuminate\Contracts\Encryption\DecryptException
*/
public function getTitleAttribute($value)
public function getTitleAttribute($value): ?string
{
if (null === $value || 0 === \strlen($value)) {
if (null === $value || '' === $value) {
return null;
}
@@ -169,13 +184,14 @@ class Attachment extends Model
/**
* @codeCoverageIgnore
*
* @param string $value
*
* @throws \Illuminate\Contracts\Encryption\EncryptException
* @param string|null $value
*/
public function setDescriptionAttribute(string $value)
public function setDescriptionAttribute(string $value = null): void
{
$this->attributes['description'] = Crypt::encrypt($value);
if (null !== $value) {
$this->attributes['description'] = Crypt::encrypt($value);
}
}
/**
@@ -185,7 +201,7 @@ class Attachment extends Model
*
* @throws \Illuminate\Contracts\Encryption\EncryptException
*/
public function setFilenameAttribute(string $value)
public function setFilenameAttribute(string $value): void
{
$this->attributes['filename'] = Crypt::encrypt($value);
}
@@ -197,7 +213,7 @@ class Attachment extends Model
*
* @throws \Illuminate\Contracts\Encryption\EncryptException
*/
public function setMimeAttribute(string $value)
public function setMimeAttribute(string $value): void
{
$this->attributes['mime'] = Crypt::encrypt($value);
}
@@ -209,9 +225,11 @@ class Attachment extends Model
*
* @throws \Illuminate\Contracts\Encryption\EncryptException
*/
public function setTitleAttribute(string $value)
public function setTitleAttribute(string $value = null): void
{
$this->attributes['title'] = Crypt::encrypt($value);
if (null !== $value) {
$this->attributes['title'] = Crypt::encrypt($value);
}
}
/**

View File

@@ -22,23 +22,34 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
use Crypt;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Collection;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Class Bill.
*
* @property bool $active
* @property int $transaction_currency_id
* @property string $amount_min
* @property string $amount_max
* @property int $id
* @property string $name
* @property bool $active
* @property int $transaction_currency_id
* @property string $amount_min
* @property string $amount_max
* @property int $id
* @property string $name
* @property Collection $notes
* @property TransactionCurrency $transactionCurrency
* @property Carbon $created_at
* @property Carbon $updated_at
* @property Carbon $date
* @property string $repeat_freq
* @property int $skip
* @property bool $automatch
* @property User $user
*/
class Bill extends Model
{

View File

@@ -22,12 +22,17 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class Note.
*
* @property int $id
* @property Carbon $created_at
* @property Carbon $updated_at
* @property string $text
* @property string $title
*/
class Note extends Model
{

View File

@@ -38,6 +38,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property string $targetamount
* @property int $id
* @property string $name
* @property Account $account
*
*/
class PiggyBank extends Model

View File

@@ -22,19 +22,30 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Collection;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Class Rule.
*
* @property bool $stop_processing
* @property int $id
* @property \Illuminate\Support\Collection $ruleTriggers
* @property bool $active
* @property bool $strict
* @property bool $stop_processing
* @property int $id
* @property Collection $ruleTriggers
* @property Collection $ruleActions
* @property bool $active
* @property bool $strict
* @property User $user
* @property Carbon $created_at
* @property Carbon $updated_at
* @property string $title
* @property string $text
* @property int $order
* @property RuleGroup $ruleGroup
*/
class Rule extends Model
{
@@ -78,9 +89,9 @@ class Rule extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany
* @return HasMany
*/
public function ruleActions()
public function ruleActions(): HasMany
{
return $this->hasMany(RuleAction::class);
}

View File

@@ -22,10 +22,20 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
* Class RuleAction.
*
* @property string $action_value
* @property string $action_type
* @property int $id
* @property Carbon $created_at
* @property Carbon $updated_at
* @property int $order
* @property bool $active
* @property bool $stop_processing
*/
class RuleAction extends Model
{

View File

@@ -22,6 +22,7 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -30,7 +31,14 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Class RuleGroup.
*
* @property bool $active
* @property bool $active
* @property User $user
* @property Carbon $created_at
* @property Carbon $updated_at
* @property string $title
* @property string $text
* @property int $id
* @property int $order
*/
class RuleGroup extends Model
{

View File

@@ -22,6 +22,7 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
@@ -29,6 +30,12 @@ use Illuminate\Database\Eloquent\Model;
*
* @property string $trigger_value
* @property string $trigger_type
* @property int $id
* @property Carbon $created_at
* @property Carbon $updated_at
* @property int $order
* @property bool $active
* @property bool $stop_processing
*/
class RuleTrigger extends Model
{