diff --git a/app/Models/Attachment.php b/app/Models/Attachment.php index d63355d..0728633 100644 --- a/app/Models/Attachment.php +++ b/app/Models/Attachment.php @@ -4,6 +4,8 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\MorphTo; class Attachment extends Model { @@ -16,11 +18,23 @@ class Attachment extends Model */ protected $fillable = [ 'media_id', + 'private', + ]; + + /** + * The default attributes. + * + * @var string[] + */ + protected $attributes = [ + 'private' => 'false', ]; /** * Get attachments attachable + * + * @return MorphTo */ public function attachable() { @@ -29,9 +43,11 @@ class Attachment extends Model /** * Get the media for this attachment. + * + * @return BelongsTo */ public function media() { return $this->belongsTo(Media::class); } -} \ No newline at end of file +} diff --git a/database/migrations/2023_05_11_032859_add_private_to_attachments_table.php b/database/migrations/2023_05_11_032859_add_private_to_attachments_table.php new file mode 100644 index 0000000..f150b3e --- /dev/null +++ b/database/migrations/2023_05_11_032859_add_private_to_attachments_table.php @@ -0,0 +1,32 @@ +boolean('private')->default(false); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('attachments', function (Blueprint $table) { + $table->dropColumn('private'); + }); + } +};