null
Find a file
Brian Faust 6470b57b87
wip
Signed-off-by: Brian Faust <brian@cline.sh>
2025-12-11 15:11:16 +02:00
.github wip 2025-12-11 15:11:16 +02:00
config first commit 2025-11-12 11:03:40 +02:00
cookbook first commit 2025-11-12 11:03:40 +02:00
database/migrations first commit 2025-11-12 11:03:40 +02:00
docker/php wip 2025-12-11 15:11:16 +02:00
src first commit 2025-11-12 11:03:40 +02:00
tests first commit 2025-11-12 11:03:40 +02:00
.editorconfig first commit 2025-11-12 11:03:40 +02:00
.gitattributes first commit 2025-11-12 11:03:40 +02:00
.gitignore first commit 2025-11-12 11:03:40 +02:00
CHANGELOG.md first commit 2025-11-12 11:03:40 +02:00
CODE_OF_CONDUCT.md first commit 2025-11-12 11:03:40 +02:00
composer.json wip 2025-12-11 15:11:16 +02:00
configure.sh first commit 2025-11-12 11:03:40 +02:00
CONTRIBUTING.md first commit 2025-11-12 11:03:40 +02:00
docker-compose.yml wip 2025-12-11 15:11:16 +02:00
ecs.php wip 2025-12-11 15:11:16 +02:00
LICENSE.md first commit 2025-11-12 11:03:40 +02:00
Makefile wip 2025-12-11 15:11:16 +02:00
phpstan.neon.dist first commit 2025-11-12 11:03:40 +02:00
phpunit.xml.dist first commit 2025-11-12 11:03:40 +02:00
README-SKELETON.md first commit 2025-11-12 11:03:40 +02:00
README.md first commit 2025-11-12 11:03:40 +02:00
rector.php wip 2025-12-11 15:11:16 +02:00
SECURITY.md first commit 2025-11-12 11:03:40 +02:00
TASKS.md first commit 2025-11-12 11:03:40 +02:00
testbench.yaml first commit 2025-11-12 11:03:40 +02:00

GitHub Workflow Status Latest Version on Packagist Software License Total Downloads


Archive

A simplified Laravel media storage package focused on storage and URL generation without image conversions.

Features

  • Simple fluent API for adding media files
  • Polymorphic relationships - attach media to any model
  • Collection organization - group media into logical collections
  • Custom path generators - full control over file organization
  • Query builder scopes - convenient filtering methods
  • Auto-cleanup - files deleted when models are removed
  • Transaction safety - atomic operations for data integrity
  • Anonymous media - orphan files without owners
  • Curator interface - support for non-Eloquent owners

Requirements

Requires PHP 8.4+

Installation

composer require cline/archive

Publish the configuration and migration:

php artisan vendor:publish --tag=archive-config
php artisan vendor:publish --tag=archive-migrations
php artisan migrate

Quick Start

1. Add trait to your model

use Cline\Archive\Contracts\Curator;
use Cline\Archive\Models\Concerns\HasArchive;

class User extends Model implements Curator
{
    use HasArchive;
}

2. Add media files

use Cline\Archive\Archive;

// Add to a model
$media = Archive::add($request->file('avatar'))
    ->toCurator($user)
    ->toCollection('avatars')
    ->store();

// Anonymous media (no curator)
$media = Archive::add($file)
    ->asAnonymous()
    ->store();

// Full featured
$media = Archive::add($file)
    ->toCurator($user)
    ->toCollection('documents')
    ->withName('Annual Report')
    ->withFileName('report-2024.pdf')
    ->toDisk('s3')
    ->withProperties(['year' => 2024])
    ->store();

3. Retrieve media

// Via relationship
$avatars = $user->media()->where('collection', 'avatars')->get();
$avatar = $user->media()->where('collection', 'avatars')->first();

// Query builder scopes
$images = Media::inCollection('avatars')
    ->ownedBy($user)
    ->ofType('image')
    ->get();

// Get URL
$url = $avatar->getUrl();

Documentation

See the cookbook directory for comprehensive guides:

Change log

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please use the GitHub security reporting form rather than the issue queue.

Credits

License

The MIT License. Please see License File for more information.