Larupload
  • 🏁Getting Started
    • Introduction
    • Installation
    • Laravel Nova integration
    • Support Us
    • License
  • 🚀Basic Usage
    • Database Preparation
    • Model Preparation
    • Upload
  • ⚙️Advanced Usage
    • Concepts
    • Configuration
      • Disk
      • Local Disk
      • Mode
      • SecureIds
      • With Meta
      • Camel Case Response
      • Hide Table Columns
      • Naming Method
      • Lang
      • Image Processing Library
      • Generate Cover
      • Cover Style
      • Dominant Color
      • Dominant Color Quality
      • Keep Old Files
      • Preserve Files
      • Store Original File Name
      • Optimize Image
      • FFMpeg
        • FFMpeg Binaries
        • FFMpeg Threads
        • FFMpeg Capture Frame
        • FFMpeg Queue
        • FFMpeg Max Queue Number
        • FFMpeg Timeout
        • FFMPEG Log Channel
    • Attachment
      • Disk
      • With Meta
      • Naming Method
      • Lang
      • Image Processing Library
      • Generate Cover
      • Cover Style
      • Dominant Color
      • Dominant Color Quality
      • Keep Old Files
      • Preserve Files
      • Store Original File Name
      • SecureIds Method
      • Optimize Image
      • Media Styles
      • Complete Example
    • Migrations
      • Heavy Columns
      • Light Columns
      • Add Original File Name to Existing Tables
  • Upload
  • Delete
  • Cover
    • Upload Cover
    • Update Cover
    • Delete Cover
  • Download
    • Generate Download Link
      • Generate URL for particular style
      • Generate URL for all styles
    • Generate Download Response
  • Meta
  • Get Attachments
  • API Resources
  • Image Optimization
  • SecureIds
  • Queue FFMpeg Processes
    • Job Completion Event
    • FFMpeg Queue Relationships
  • 🧱Standalone Uploader
    • Introduction
    • Upload
    • Delete
    • Cover
      • Update Cover
      • Delete Cover
    • Customization
  • ⚪OTHER
    • Migration
Powered by GitBook
On this page
Edit on GitHub
  1. Advanced Usage
  2. Attachment

Preserve Files

The preserveFiles function on the Attachment is used to enable or disable the preservation of files when deleting a record. When this function is enabled, Larupload will not delete the files associated with a record even when the record is deleted from the database. This can be useful in situations where you want to keep the files for some other purpose, even after the associated record has been deleted. By default, preserveFiles is set to false which means that files will be deleted when the associated record is deleted from the database.

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Mostafaznv\Larupload\Storage\Attachment;
use Mostafaznv\Larupload\Traits\Larupload;

class Media extends Model
{
    use Larupload;

    public function attachments(): array
    {
        return [
            Attachment::make('file')->preserveFiles(true)
        ];
    }
}

PreviousKeep Old FilesNextStore Original File Name

Last updated 2 years ago

⚙️