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

Get Attachments

The getAttachments function allows you to retrieve all URLs and meta information for the attachments assigned to a model. If no argument is provided, it returns URLs and meta for all attachments. However, you can pass the attachment name as an argument to retrieve the data for a specific attachment.

$user = User::query()->first();
$attachments = $user->getAttachments();
Output
{
  "avatar": {
    "original": "https://larupload.dev/storage/users/1/avatar/original/image.jpg",
    "thumbnail": "https://larupload.dev/storage/users/1/avatar/thumbnail/image.jpg",
    "cover": "https://larupload.dev/storage/users/1/avatar/cover/image.jpg",
    "meta": {
       "name": "image.jpg",
       "id": "1",
       "original_name": "image.jpg"
       "size": 35700,
       "type": "IMAGE",
       "mime_type": "image/jpeg",
       "width": 1077,
       "height": 791,
       "duration": null,
       "dominant_color": "#f4c00a",
       "format": "jpg",
       "cover": "image.jpg"
    }
  },
  "cv": {
    "original": "https://larupload.dev/storage/users/1/cv/original/cv.pdf",
    "cover": "https://larupload.dev/storage/users/1/cv/cover/cv.jpg",
    "meta": {
       "name": "cv.pdf",
       "id": "1",
       "original_name": "image.jpg"
       "size": 71710,
       "type": "DOCUMENT",
       "mime_type": "application/pdf",
       "width": null,
       "height": null,
       "duration": null,
       "dominant_color": "#f4c00a",
       "format": "pdf",
       "cover": "cv.jpg"
    }
  }
}
$user = User::query()->first();
$attachment = $user->getAttachments('avatar');
Output
{
   "original": "https://larupload.dev/storage/users/1/avatar/original/image.jpg",
   "thumbnail": "https://larupload.dev/storage/users/1/avatar/thumbnail/image.jpg",
   "cover": "https://larupload.dev/storage/users/1/avatar/cover/image.jpg",
   "meta": {
       "name": "image.jpg",
       "id": "1",
       "original_name": "image.jpg"
       "size": 35700,
       "type": "IMAGE",
       "mime_type": "image/jpeg",
       "width": 1077,
       "height": 791,
       "duration": null,
       "dominant_color": "#f4c00a",
       "format": "jpg",
       "cover": "image.jpg"
    }
 }

PreviousMetaNextAPI Resources

Last updated 10 months ago