A simple Laravel package to manage links. Polymorphic many-to-many relationship between links and any model.

Installs: 2

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/italofantone/links

v1.0.0 2025-10-21 21:13 UTC

This package is auto-updated.

Last update: 2025-11-21 21:27:47 UTC


README

A simple Laravel package to manage links. Polymorphic many-to-many relationship between links and any model.

Example: A Post model can have many links, and a User model can also have many links. Links can be shared among different models.

⚠️ This code was used for educational purposes [...]

Installation

composer require italofantone/links

Usage

  1. Run migrations:
php artisan migrate
  1. Use the Linkable trait in any model you want to associate links with:
use Italofantone\Links\Traits\Linkable;

class Post extends Model
{
    use Linkable;
}
  1. Now you can attach, and detach links with your models:
$post = Post::find(1);
$link = Link::find(1);

// Attach a link to a post
$post->attachLink($link);

// Detach a link from a post
$post->detachLink($link);

// Get all links associated with a post
$links = $post->links;

Contact

Donations

If you find this project useful and would like to support its development, you can make a donation via PayPal:

Thank you for your support!