multicaret/laravel-acquaintances
Composer 安装命令:
composer require multicaret/laravel-acquaintances
包简介
This light package, with no dependencies, gives Eloquent models the ability to manage friendships (with groups), verifications, and interactions such as: Likes, favorites, votes, subscribe, follow, ..etc. And it includes advanced rating system.
关键字:
README 文档
README
Clean, modular social features for Eloquent models: Friendships, Verifications, Interactions (Follow/Like/Favorite/Report/Subscribe/Vote/View), and multi-type Ratings.
- PHP >= 8.1
- Illuminate components ^9.0 | ^10.0 | ^11.0 | ^12.0 | ^13.0 (Laravel 9–13)
- Laravel News: https://laravel-news.com/manage-friendships-likes-and-more-with-the-acquaintances-laravel-package
What's New in v4
- UUID / ULID morph support — configurable per table via
morphs,uuidMorphs, orulidMorphs. - Caching layer — in-memory request cache + optional persistent cache for interaction checks with automatic invalidation.
withAcquaintanceCounts()macro — eager-load interaction counts in a single query.HasAcquaintanceCounterstrait — auto-increment/decrement counter columns on your model's table.AcquaintancesCleanupJob— queued mass deletion of acquaintance data for deleted models.- Database indexes — composite and unique indexes on all tables for faster lookups.
- Morph map registration — automatic morph map for all package models.
- Strict return types on all traits and models.
- DB transactions for
blockFriend()andblockVerification(). - Interactions-only mode — disable friendships and/or verifications via
featuresconfig to skip their migrations entirely. Granular per-feature publish tags available.
See CHANGELOG.md for the full list and Upgrade Notes for migration steps.
TL;DR
$user1 = User::find(1); $user2 = User::find(2); // Friendships $user1->befriend($user2); $user2->acceptFriendRequest($user1); // The messy breakup :( $user2->unfriend($user1); // Verifications (message is optional) $user1->verify($user2, "Worked together on several Laravel projects."); $user2->acceptVerificationRequest($user1); if ($user1->isVerifiedWith($user2)) { echo "Verified!"; }
Documentation
To keep this README concise, the full documentation lives under docs/:
- Overview
- Installation
- Configuration
- Friendships
- Verifications
- Interactions (Follow/Like/Favorite/Report/Subscribe/Vote/View)
- Ratings
- Migrations
- Events
- Testing
- FAQ
- Upgrade Notes
Quickstart
- Install
composer require multicaret/laravel-acquaintances
- Publish (optional) and migrate
php artisan vendor:publish --provider="Multicaret\\Acquaintances\\AcquaintancesServiceProvider"
php artisan migrate
Interactions-Only Mode
If you only need interactions (Follow, Like, Favorite, Subscribe, Vote, View, Report, Rate) and don't need Friendships or Verifications, disable them in config/acquaintances.php:
'features' => [ 'interactions' => true, 'friendships' => false, 'verifications' => false, ],
This prevents friendship and verification migrations from being loaded or published, keeping your database lean.
You can also publish migrations for specific features using granular tags:
# Only interaction migrations php artisan vendor:publish --tag=acquaintances-migrations-interactions # Only friendship migrations php artisan vendor:publish --tag=acquaintances-migrations-friendships # Only verification migrations php artisan vendor:publish --tag=acquaintances-migrations-verifications
Custom User Model Location
If your User model lives in a non-standard namespace (e.g., App\Models\Core\User), set user_model_class_name in config/acquaintances.php:
'user_model_class_name' => \App\Models\Core\User::class,
When null (default), the package resolves the user model from model_namespace + models.user (i.e., App\Models\User).
- Add traits to your models
use Multicaret\\Acquaintances\\Traits\\Friendable; use Multicaret\\Acquaintances\\Traits\\Verifiable; use Multicaret\\Acquaintances\\Traits\\CanFollow; use Multicaret\\Acquaintances\\Traits\\CanBeFollowed; use Multicaret\\Acquaintances\\Traits\\CanLike; use Multicaret\\Acquaintances\\Traits\\CanBeLiked; use Multicaret\\Acquaintances\\Traits\\CanRate; use Multicaret\\Acquaintances\\Traits\\CanBeRated; class User extends Model { use Friendable, Verifiable; use CanFollow, CanBeFollowed; use CanLike, CanBeLiked; use CanRate, CanBeRated; }
Explore the feature guides linked above for full APIs and examples.
Compatibility
| Version | PHP | Laravel |
|---|---|---|
| v4 | >= 8.1 | 9, 10, 11, 12, 13 |
| v3.x | >= 8.0 | 9, 10, 11, 12 |
Contributing / Changelog
- Contributing: see CONTRIBUTING.md
- Changes: see CHANGELOG.md
multicaret/laravel-acquaintances 适用场景与选型建议
multicaret/laravel-acquaintances 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 286.23k 次下载、GitHub Stars 达 848, 最近一次更新时间为 2020 年 04 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「friends」 「friendships」 「Rating」 「like」 「eloquent」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 multicaret/laravel-acquaintances 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 multicaret/laravel-acquaintances 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 multicaret/laravel-acquaintances 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Eloquent Befriended brings social media-like features like following, blocking and filtering content based on following or blocked models.
This package gives Eloquent models the ability to manage their followers.
This package gives Eloquent models the ability to manage their friendships.
Alfabank REST API integration
This package gives Eloquent models the ability to manage their friendships.
This light package, with no dependencies, gives Eloquent models the ability to manage friendships (with groups). And interactions such as: Likes, favorites, votes, subscribe, follow, ..etc. And it includes advanced rating system.
统计信息
- 总下载量: 286.23k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 852
- 点击次数: 45
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-04-04