### Basic Customization Example Source: https://github.com/mostafaznv/larupload/blob/master/docs/standalone-uploader/customization.md Demonstrates initializing the uploader with a path, specifying a disk, customizing the naming method, and defining various media styles and streams for image, video, and audio uploads. ```php $file = $request->file('file'); $cover = $request->file('cover'); $upload = Larupload::init('path') ->disk('s3') ->namingMethod(LaruploadNamingMethod::HASH_FILE) ->image('thumbnail', 1000, 750, LaruploadMediaStyle::CROP) ->video('thumbnail', 1000, 750, LaruploadMediaStyle::CROP) ->audio('wav', new Wav()) ->stream( name: '480p', width: 640, height: 480, format: (new X264) ->setKiloBitrate(3000) ->setAudioKiloBitrate(64) ) ) ->upload($file, $cover); ``` -------------------------------- ### Camel Case Response Example Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/configuration/camel-case-response.md This JSON output demonstrates the camelCase style for meta keys when the option is enabled. ```json { "name": "image.jpg", "id": "1", "originalName": "image.jpg" "size": 35700, "type": "IMAGE", "mimeType": "image/jpeg", "width": 1077, "height": 791, "duration": null, "dominantColor": "#f4c00a", "format": "jpg", "cover": "image.jpg" } ``` -------------------------------- ### Complete Attachment Configuration Example Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/attachment/complete-example.md This snippet shows a full configuration of an attachment with various processing options for images, audio, video, and streams. It includes meta data handling, naming conventions, and style definitions. ```php disk('local') ->withMeta(true) ->namingMethod(LaruploadNamingMethod::HASH_FILE) ->lang('fa') ->imageProcessingLibrary(LaruploadImageLibrary::GD) ->generateCover(false) ->dominantColor(true) ->dominantColorQuality(5) ->keepOldFiles(true) ->preserveFiles(true) ->secureIdsMethod(LaruploadSecureIdsMethod::ULID) ->optimizeImage(true) ->coverStyle('cover', 400, 400, LaruploadMediaStyle::CROP) ->image('thumbnail', 250, 250, LaruploadMediaStyle::AUTO) ->image('crop_mode', 1100, 1100, LaruploadMediaStyle::CROP) ->image('portrait_mode', 1000, 1000, LaruploadMediaStyle::SCALE_WIDTH) ->audio('audio_wav', new Wav()) ->audio('audio_flac', new Flac()) ->audio('audio_aac', new Aac()) ->audio( name: 'audio_mp3', format: (new Mp3())->setAudioKiloBitrate(192)->setAudioChannels(2) ) ->video('thumbnail', 250, 250, LaruploadMediaStyle::AUTO) ->video('crop_mode', 1100, 1100, LaruploadMediaStyle::CROP) ->video('portrait_mode', 1000, 1000, LaruploadMediaStyle::SCALE_WIDTH) ->video(name: 'mp3', format: new Mp3) ->video( name: 'auto', width: 300, height: 190, mode: LaruploadMediaStyle::AUTO, format: (new X264) ->setKiloBitrate(1000) ->setAudioKiloBitrate(64) ) ->stream( name: '480p', width: 640, height: 480, format: (new X264) ->setKiloBitrate(3000) ->setAudioKiloBitrate(64) ) ->stream( name: '720p', width: 1280, height: 720, format: (new X264) ->setKiloBitrate(1000) ->setAudioKiloBitrate(64) ) Attachment::make('other_file', LaruploadMode::LIGHT) ->stream( name: '480p', width: 640, height: 480, format: (new X264) ->setKiloBitrate(3000) ->setAudioKiloBitrate(64) ->setAudioChannels(1) ->setAudioCodec('libmp3lame') ) ]; } } ``` -------------------------------- ### Response with Metadata Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/configuration/with-meta.md This is an example of the JSON output when the 'withMeta' property is enabled. It includes original, thumbnail, and cover URLs, along with a 'meta' object containing file details like name, size, type, dimensions, dominant color, and format. ```json { "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" } } ``` -------------------------------- ### Example Output of URLs Method Source: https://github.com/mostafaznv/larupload/blob/master/docs/download/generate-download-link/generate-url-for-all-styles.md The `urls()` method returns a JSON object where keys are style names and values are the corresponding URLs. This includes the 'original' style and any custom styles defined. ```json { "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" } ``` -------------------------------- ### Upload Output Example Source: https://github.com/mostafaznv/larupload/blob/master/docs/standalone-uploader/upload.md This JSON represents the successful output from the Larupload `upload` method. It includes details about the original file, its meta-information, and the generated cover image. ```json { "original": "http://larupload.site/storage/uploader/original/a3ac7ddabb263c2d00b73e8177d15c8d.mp4", "meta": { "name": "a3ac7ddabb263c2d00b73e8177d15c8d.mp4", "id": "125940123", "original_name": "video.mp4", "size": 383631, "type": "video", "width": 560, "height": 320, "duration": 5, "format": "mp4", "cover": "66ad2a5ebfe7ea349c8b861399c060d8.jpeg", "mime_type": "video/mp4", "dominant_color": "#e5d2d4" } } ``` -------------------------------- ### Install Larupload via Composer Source: https://github.com/mostafaznv/larupload/blob/master/docs/getting-started/installation.md Use this command to add the Larupload package to your Laravel project dependencies. ```shell composer require mostafaznv/larupload ``` -------------------------------- ### Example Attachment Metadata Output Source: https://github.com/mostafaznv/larupload/blob/master/docs/meta.md This JSON object represents the full metadata returned by the meta method when called without arguments. It includes details like name, size, dimensions, and color. ```json { "name": "9e55cf595703eaa109025073caed65a4.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": "9e55cf595703eaa109025073caed65a4.jpg" } ``` -------------------------------- ### Generate URL for the Original Attachment File Source: https://github.com/mostafaznv/larupload/blob/master/docs/download/generate-download-link/generate-url-for-particular-style.md Use this to get the URL for the original, unprocessed file. This is the default behavior if no style is specified. ```php $model->attachment('avatar')->url(); ``` ```php $model->attachment('avatar')->url('original'); ``` -------------------------------- ### Get URLs with Metadata Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/configuration/with-meta.md Call the 'urls' function on an attachment to retrieve file URLs along with their associated metadata. This requires the 'withMeta' property to be enabled in the configuration. ```php $user->attachment('avatar')->urls(); ``` -------------------------------- ### Retrieve Attachment Size Source: https://github.com/mostafaznv/larupload/blob/master/docs/meta.md Use this snippet to get the size of a specific attachment. Ensure the attachment name is correct. ```php $size = $model->attachment('file')->meta('size'); ``` -------------------------------- ### Get All Attachments Source: https://github.com/mostafaznv/larupload/blob/master/docs/get-attachments.md Call getAttachments without arguments to retrieve all attachments and their metadata for a model. This is useful when you need a comprehensive list of all associated files. ```php $user = User::query()->first(); $attachments = $user->getAttachments(); ``` ```json { "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" } } } ``` -------------------------------- ### Get Particular Attachment Source: https://github.com/mostafaznv/larupload/blob/master/docs/get-attachments.md Pass the attachment name as an argument to getAttachments to retrieve data for a specific attachment. This is useful when you only need information about one file. ```php $user = User::query()->first(); $attachment = $user->getAttachments('avatar'); ``` ```json { "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" } } ``` -------------------------------- ### Generate URL for a Specific Attachment Style Source: https://github.com/mostafaznv/larupload/blob/master/docs/download/generate-download-link/generate-url-for-particular-style.md Use this to get the URL for a processed style (e.g., 'thumb') of an attachment. Ensure the style has been previously generated. ```php $model->attachment('avatar')->url('thumb'); ``` -------------------------------- ### Run Database Migrations Source: https://github.com/mostafaznv/larupload/blob/master/docs/getting-started/installation.md Execute this command to create the necessary database tables for Larupload. ```shell php artisan migrate ``` -------------------------------- ### Retrieve Attachment MIME Type Source: https://github.com/mostafaznv/larupload/blob/master/docs/meta.md Use this snippet to get the MIME type of a specific attachment. Ensure the attachment name is correct. ```php $mime = $model->attachment('file')->meta('mime_type'); ``` -------------------------------- ### Publish Configuration File Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/configuration/README.md Run this artisan command to publish the Larupload configuration file to your project. ```bash php artisan vendor:publish --provider="Mostafaznv\Larupload\LaruploadServiceProvider" ``` -------------------------------- ### Create Table with Light Column Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/migrations/light-columns.md Use this migration to create a table with a 'file' column in Larupload's LIGHT mode. This mode stores only the file name and meta information. ```php id(); $table->upload('file', LaruploadMode::LIGHT); $table->timestamps(); }); } public function down() { Schema::dropIfExists('uploads'); } }; ``` -------------------------------- ### Create Larupload Event Listener Source: https://github.com/mostafaznv/larupload/blob/master/docs/queue-ffmpeg-processes/job-completion-event.md Use the Artisan command to generate a new listener for Larupload FFMpeg queue events. ```bash php artisan make:listener LaruploadFFMpegQueueNotification ``` -------------------------------- ### Enable FFMpeg Queue Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/configuration/ffmpeg/ffmpeg-queue.md Set the 'queue' option to true in the configuration file to enable background FFMpeg processing. Ensure a queue worker is set up to handle the jobs. ```php [ 'queue' => true ] ]; ``` -------------------------------- ### Set FFmpeg and FFprobe Binaries Path Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/configuration/ffmpeg/ffmpeg-binaries.md Specify custom paths for the FFmpeg and FFprobe binaries in the Larupload configuration file. This is useful when the binaries are not automatically detected in the system's environment path. ```php [ 'ffmpeg.binaries' => '/usr/local/bin/ffmpeg', 'ffprobe.binaries' => '/usr/local/bin/ffprobe' ] ]; ``` -------------------------------- ### Enable Image Optimization in Larupload Source: https://github.com/mostafaznv/larupload/blob/master/docs/image-optimization.md This configuration snippet shows how to enable image optimization in Larupload by setting 'enable' to true and configuring various optimizers for different image formats. It also includes options for timeout and specific optimizer parameters. ```php [ 'enable' => false, 'timeout' => 60, 'optimizers' => [ Spatie\ImageOptimizer\Optimizers\Jpegoptim::class => [ '-m85', // set maximum quality to 85% '--force', // ensure that progressive generation is always done also if a little bigger '--strip-all', // this strips out all text information such as comments and EXIF data '--all-progressive', // this will make sure the resulting image is a progressive one ], Spatie\ImageOptimizer\Optimizers\Pngquant::class => [ '--force', // required parameter for this package ], Spatie\ImageOptimizer\Optimizers\Optipng::class => [ '-i0', // this will result in a non-interlaced, progressive scanned image '-o2', // this set the optimization level to two (multiple IDAT compression trials) '-quiet', // required parameter for this package ], Spatie\ImageOptimizer\Optimizers\Svgo::class => [ '--config=svgo.config.js', // disabling because it is known to cause troubles ], Spatie\ImageOptimizer\Optimizers\Gifsicle::class => [ '-b', // required parameter for this package '-O3', // this produces the slowest but best results ], Spatie\ImageOptimizer\Optimizers\Cwebp::class => [ '-m 6', // for the slowest compression method in order to get the best compression. '-pass 10', // for maximizing the amount of analysis pass. '-mt', // multithreading for some speed improvements. '-q 90', //quality factor that brings the least noticeable changes. ], ] ] ]; ``` -------------------------------- ### Define Audio Styles for Conversion Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/attachment/media-styles.md Configure audio styles using the `audio` method in Larupload's `Attachment`. This allows for format conversion, specifying the desired audio format. ```php audio('hq', new Wav()) ]; } } ``` -------------------------------- ### Download Particular Style Source: https://github.com/mostafaznv/larupload/blob/master/docs/download/generate-download-response.md Specify a style name as an argument to the `download` method to serve a particular styled version of the file. ```php $user->attachment('avatar')->download('thumbnail'); ``` -------------------------------- ### Attaching a Cover with a File Source: https://github.com/mostafaznv/larupload/blob/master/docs/cover/upload-cover.md Use the `attach()` function to upload a file and its associated cover. The cover is passed as the second argument. This prevents the package from automatically creating a cover. ```php $file = $request->file('file'); $cover = $request->file('cover'); # or $upload->attachment('file')->attach($file, $cover); $upload->save(); ``` -------------------------------- ### Download Original File Source: https://github.com/mostafaznv/larupload/blob/master/docs/download/generate-download-response.md Call the `download` method on an attachment instance without arguments to serve the original file. ```php $user->attachment('avatar')->download(); ``` -------------------------------- ### Create and Upload File in One Line Source: https://github.com/mostafaznv/larupload/blob/master/docs/upload.md Create and upload a file simultaneously by passing the file to the 'create' method of your model. This is useful for single-line operations. ```php $upload = Upload::create([ 'file' => $request->file('file') ]); ``` -------------------------------- ### Accessing FFMpeg Queue Status with Relationships Source: https://github.com/mostafaznv/larupload/blob/master/docs/queue-ffmpeg-processes/ffmpeg-queue-relationships.md Use the `with` method to eager load both the current FFMpeg job status (`laruploadQueue`) and the history of all FFMpeg jobs (`laruploadQueues`) for a specific upload record. ```php Upload::query() ->where('id', 21) ->with('laruploadQueue', 'laruploadQueues') ->first(); ``` -------------------------------- ### Define Stream Styles Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/attachment/media-styles.md Set up stream styles with specific resolutions and encoding formats. Allows detailed control over video and audio kilobitrates for each stream quality. ```php stream( name: '480p', width: 640, height: 480, format: (new X264) ->setKiloBitrate(1000) ->setAudioKiloBitrate(32) ) ->stream( name: '720p', width: 1280, height: 720, format: (new X264) ->setKiloBitrate(3000) ->setAudioKiloBitrate(64) ) ]; } } ``` -------------------------------- ### Define Video Styles Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/attachment/media-styles.md Configure different video styles like thumbnails and landscapes with specific dimensions and manipulation modes. Supports custom audio formats. ```php video('thumbnail', 250, 250, LaruploadMediaStyle::CROP) ->video('landscape', 1100, 1100, LaruploadMediaStyle::AUTO) ->video(name: 'mp3', format: new Mp3) ]; } } ``` -------------------------------- ### Default Cover Style Configuration Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/configuration/cover-style.md Sets the cover image to a 500x500 pixel dimension with center cropping. Use this to define the default appearance of generated cover images. ```php ImageStyle::make( name: 'cover', width: 500, height: 500, mode: LaruploadMediaStyle::CROP ) ]; ``` -------------------------------- ### Handle Larupload Job Completion Event Source: https://github.com/mostafaznv/larupload/blob/master/docs/queue-ffmpeg-processes/job-completion-event.md Implement the handle method in your listener to process the LaruploadFFMpegQueueFinished event and access job details. ```php id, model: $event->model, statusId: $event->statusId"); } } ``` -------------------------------- ### Create Uploads Table with Heavy Columns Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/migrations/heavy-columns.md This snippet demonstrates how to define a database table schema using Larupload's HEAVY mode. The `upload` method with `LaruploadMode::HEAVY` automatically creates multiple columns to store detailed file information. ```php id(); $table->upload('file', LaruploadMode::HEAVY); $table->timestamps(); }); } public function down() { Schema::dropIfExists('uploads'); } }; ``` -------------------------------- ### Register Larupload Event Listener Source: https://github.com/mostafaznv/larupload/blob/master/docs/queue-ffmpeg-processes/job-completion-event.md Register the created listener in your EventServiceProvider to handle the LaruploadFFMpegQueueFinished event. ```php use App\Events\OrderShipped; use Mostafaznv\Larupload\Events\LaruploadFFMpegQueueFinished; use App\Listeners\LaruploadFFMpegQueueNotification; protected $listen = [ LaruploadFFMpegQueueFinished::class => [ LaruploadFFMpegQueueNotification::class, ], ]; ``` -------------------------------- ### Set Attachment Disk to S3 Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/attachment/disk.md Use the `disk` method to specify 's3' as the storage disk for the 'file' attachment. Ensure the 's3' disk is defined in your `config/filesystems.php`. ```php disk('s3') ]; } } ``` -------------------------------- ### Add Upload Columns to Database Table Source: https://github.com/mostafaznv/larupload/blob/master/docs/basic-usage/database-preparation.md Use the `upload` macro within your migration file to add columns required by Larupload. This macro handles the creation of necessary fields for storing file information. Specify the column name and the desired `LaruploadMode` (e.g., HEAVY or LIGHT). ```php id(); $table->upload('main_file', LaruploadMode::HEAVY); $table->upload('other_file', LaruploadMode::LIGHT); $table->timestamps(); }); } public function down() { Schema::dropIfExists('uploads'); } }; ``` -------------------------------- ### Enable Image Optimization Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/attachment/optimize-image.md Enable image optimization for a specific attachment by calling `optimizeImage(true)` within the attachment configuration. This ensures uploaded images are processed to reduce file size. ```php optimizeImage(ture) ]; } } ``` -------------------------------- ### Set Attachment Naming Method to HASH_FILE Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/attachment/naming-method.md Use the namingMethod() function with LaruploadNamingMethod::HASH_FILE to generate a unique filename based on the file's content using MD5 hashing. This ensures that files with identical content will have the same name. ```php namingMethod(LaruploadNamingMethod::HASH_FILE) ]; } } ``` -------------------------------- ### Upload File using Mutator Source: https://github.com/mostafaznv/larupload/blob/master/docs/upload.md Assign the file directly to a model property defined in the 'attachments' method. This is the simplest upload method. ```php $upload = new Upload; $upload->file = $request->file('file'); $upload->save(); ``` -------------------------------- ### Set Attachment Cover Style Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/attachment/cover-style.md Use the `coverStyle` method within the `Attachment::make()` configuration to specify the name, dimensions, and style for a cover image. The style `LaruploadMediaStyle::CROP` is used here for a 400x400 pixel cover. ```php coverStyle('cover', 400, 400, LaruploadMediaStyle::CROP) ]; } } ``` -------------------------------- ### Enable Metadata for Attachment Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/attachment/with-meta.md Call the `withMeta(true)` method on an attachment instance to include metadata in the `urls` method response. This metadata can include file format, dimensions, and dominant color. ```php withMeta(true) ]; } } ``` -------------------------------- ### Setting Secure IDs Method to ULID Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/attachment/secureids-method.md This snippet demonstrates how to configure the file upload path to use the ULID format for generating secure IDs. Ensure the `LaruploadSecureIdsMethod` enum is imported. ```php secureIdsMethod(LaruploadSecureIdsMethod::ULID) ]; } } ``` -------------------------------- ### Standalone File Upload Controller Source: https://github.com/mostafaznv/larupload/blob/master/docs/standalone-uploader/upload.md Use this snippet to upload a file and an optional cover image in a Laravel controller. It initializes Larupload with a base path and calls the upload method. ```php file('file'); $cover = $request->file('cover'); $upload = Larupload::init('your/base/path')->upload($file, $cover); return response()->json($upload); } } ``` -------------------------------- ### Retrieve All Attachment Metadata Source: https://github.com/mostafaznv/larupload/blob/master/docs/meta.md Call the meta method without arguments to retrieve all available metadata for an attachment. This provides a comprehensive overview of the file. ```php $meta = $model->attachment('file')->meta(); ``` -------------------------------- ### Define Model Attachments with Larupload Trait Source: https://github.com/mostafaznv/larupload/blob/master/docs/basic-usage/model-preparation.md Add the `Larupload` trait to your model and define the `attachments` method to specify file entities. Use `LaruploadMode::LIGHT` for optimized storage. ```php imageProcessingLibrary(LaruploadImageLibrary::GD) ]; } } ``` -------------------------------- ### Retrieve Upload Attachments as Array or JSON Source: https://github.com/mostafaznv/larupload/blob/master/docs/api-resources.md Fetch the first upload record and then convert its attachments to an array or JSON format using the built-in methods. ```php $upload = Upload::query()->first(); $upload->toArray(); $upload->toJson(); ``` -------------------------------- ### Define Image Styles for Uploads Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/attachment/media-styles.md Use the `image` method within the `Attachment` configuration to define styles for image manipulation. Specify the style name, dimensions, and manipulation mode. ```php image('thumbnail', 250, 250, LaruploadMediaStyle::CROP) ->image('landscape', 1100, 1100, LaruploadMediaStyle::AUTO) ]; } } ``` -------------------------------- ### Capture Frame: Specific Time (0.1s) Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/configuration/ffmpeg/ffmpeg-capture-frame.md Specify a precise time in seconds (e.g., 0.1) to capture a frame from the video. This allows for targeted frame extraction. ```php [ 'capture-frame' => 0.1 ] ]; ``` -------------------------------- ### Enable Keep Old Files for an Attachment Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/attachment/keep-old-files.md Configure an attachment to keep its old files when updating the database record by calling `keepOldFiles(true)` on the Attachment instance. ```php keepOldFiles(true) ]; } } ``` -------------------------------- ### Enable File Preservation for Attachments Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/attachment/preserve-files.md Configure an attachment to preserve its associated files even when the parent record is deleted. By default, files are deleted when the record is removed. ```php preserveFiles(true) ]; } } ``` -------------------------------- ### Add Original File Name Column Migration Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/migrations/add-original-file-name-to-existing-tables.md Use this migration to add the 'file_original_name' column to your 'media' table. The first argument must match the first argument of the 'upload' method. ```php laruploadAddOriginalName('file'); }); } }; ``` -------------------------------- ### Capture Frame: Null (Automatic) Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/configuration/ffmpeg/ffmpeg-capture-frame.md Set 'capture-frame' to null to automatically capture a frame from the center of the video file. This is the default behavior if no value is specified. ```php [ 'capture-frame' => null ] ]; ``` -------------------------------- ### Capture Frame: Specific Time (2s) Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/configuration/ffmpeg/ffmpeg-capture-frame.md Configure FFmpeg to capture a frame at a specific second mark (e.g., 2 seconds) within the video file during the upload process. ```php [ 'capture-frame' => 2 ] ]; ``` -------------------------------- ### Delete Cover in Standalone Mode Source: https://github.com/mostafaznv/larupload/blob/master/docs/standalone-uploader/cover/delete-cover.md Use the `deleteCover` method to remove the cover file for an attachment in standalone mode. Ensure Larupload is initialized with the correct base path. ```php deleteCover(); return redirect()->back(); } } ``` -------------------------------- ### Set Attachment Language to Persian Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/attachment/lang.md This snippet demonstrates how to set the language for file name generation to Persian ('fa') for a specific attachment instance named 'file'. ```php lang('fa') ]; } } ``` -------------------------------- ### Update File Cover Source: https://github.com/mostafaznv/larupload/blob/master/docs/cover/update-cover.md Update the cover of an existing upload. You can use either the direct relationship or the recommended attachment helper method. Ensure the upload is saved after the update. ```php $cover = $request->file('cover'); $upload = Upload::query()->first(); $upload->file->cover()->update($cover); # or (recommended) $upload->attachment('file')->cover()->update($cover); $upload->save(); ``` -------------------------------- ### Delete File by Assigning LARUPLOAD_NULL (Deprecated) Source: https://github.com/mostafaznv/larupload/blob/master/docs/delete.md This method of assigning `LARUPLOAD_NULL` to the file property is deprecated since version 3.0.0. The `detach` method or assigning `false` are recommended alternatives. Call `save()` to commit. ```php $upload->file = LARUPLOAD_NULL; $upload->save(); ``` -------------------------------- ### Set Dominant Color Quality Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/attachment/dominant-color-quality.md Configure the dominant color extraction quality for an attachment. Use a value between 1 (highest quality) and 10 (default). Higher values increase accuracy but may require more resources. ```php dominantColorQuality(6) ]; } } ``` -------------------------------- ### Update Attachment Cover Source: https://github.com/mostafaznv/larupload/blob/master/docs/standalone-uploader/cover/update-cover.md Use the `changeCover` method to update the cover file for an attachment in standalone mode. This method requires the new cover file as an argument. ```php file('cover'); Larupload::init('uploaded/base/path')->changeCover($cover); return redirect()->back(); } } ``` -------------------------------- ### Disable Cover Image Generation Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/attachment/generate-cover.md Set `generateCover` to `false` within the `Attachment` configuration to prevent Larupload from automatically generating a cover image from uploaded media. This is useful when you do not need a preview. ```php generate(false) ]; } } ``` -------------------------------- ### Delete File by Detach Source: https://github.com/mostafaznv/larupload/blob/master/docs/delete.md Use the `detach()` method on the file instance or via the `attachment()` helper to remove a file. Remember to call `save()` to persist the changes. ```php $upload->file->detach(); # or (recommended) $upload->attachment('file')->detach(); $upload->save(); ``` -------------------------------- ### Enable Storing Original File Name Source: https://github.com/mostafaznv/larupload/blob/master/docs/advanced-usage/attachment/store-original-file-name.md Use `storeOriginalFileName(true)` within the `Attachment::make()` configuration to enable storing the original file name. This feature is deprecated since v3.0.0 and is now enabled by default. ```php storeOriginalFileName(true) ]; } } ``` -------------------------------- ### Delete File by Assigning False Source: https://github.com/mostafaznv/larupload/blob/master/docs/delete.md Assign `false` to the file property to delete it. This method was introduced in version 3.0.0. Ensure `save()` is called afterwards. ```php $upload->file = false; $upload->save(); ```