diff --git a/app/Models/Attachment.php b/app/Models/Attachment.php new file mode 100644 index 0000000000..1df6a57025 --- /dev/null +++ b/app/Models/Attachment.php @@ -0,0 +1,36 @@ +morphTo(); + } + + /** + * @codeCoverageIgnore + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function user() + { + return $this->belongsTo('FireflyIII\User'); + } + +} \ No newline at end of file diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php index 1d2fd4caf6..ac566b257e 100644 --- a/app/Models/TransactionJournal.php +++ b/app/Models/TransactionJournal.php @@ -467,6 +467,14 @@ class TransactionJournal extends Model $this->attributes['encrypted'] = true; } + /** + * @return \Illuminate\Database\Eloquent\Relations\MorphMany + */ + public function attachments() + { + return $this->morphMany('App\Models\Attachment', 'attachable'); + } + /** * @codeCoverageIgnore * @return \Illuminate\Database\Eloquent\Relations\BelongsTo diff --git a/app/User.php b/app/User.php index 4c879febf4..15ba001284 100644 --- a/app/User.php +++ b/app/User.php @@ -66,6 +66,14 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon return $this->hasMany('FireflyIII\Models\Account'); } + /** + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function attachments() + { + return $this->hasMany('FireflyIII\Models\Attachment'); + } + /** * @return \Illuminate\Database\Eloquent\Relations\HasMany */ diff --git a/database/migrations/2015_07_17_190438_changes_for_v3410.php b/database/migrations/2015_07_17_190438_changes_for_v3410.php new file mode 100644 index 0000000000..68330ac890 --- /dev/null +++ b/database/migrations/2015_07_17_190438_changes_for_v3410.php @@ -0,0 +1,46 @@ +increments('id'); + $table->timestamps(); + $table->softDeletes(); + $table->integer('attachable_id')->unsigned(); + $table->string('attachable_type'); + $table->integer('user_id')->unsigned(); + $table->string('md5', 32); + $table->string('filename'); + $table->string('mime'); + $table->integer('size')->unsigned(); + $table->tinyInteger('uploaded', false, true)->default(0); + + } + ); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('attachments'); + + } +}