elbgoods/eloquent-sync-one-to-many
最新稳定版本:0.3.0
Composer 安装命令:
composer require elbgoods/eloquent-sync-one-to-many
包简介
README 文档
README
This package provides the sync function for one to many relations similar to the sync method from BelongsToMany.
Installation
You can install the package via composer:
composer require elbgoods/eloquent-sync-one-to-many
Usage
Sync using ids
$user->tasks()->sync([1, 2, 4]);
Sync using ids and additional attributes
$user->tasks()->sync([ 1 => ['status' => 'wip', 'priority' => 1], 4 => ['status' => 'finished', 'priority' => 3], ]);
Sync without detaching
$user->tasks()->syncWithoutDetaching([1, 2, 4]); // or $user->tasks()->sync([1, 2, 4], ['detaching' => false]);
Sync and set additional attributes to detached
$user->tasks()->sync( [1, 2, 4], 'set_after_detach' => [ 'status' => 'open', 'priority' => 0, ], );
Sync using values by given key as ids
$user->tasks()->sync([ ['task_id' => 1, 'status' => 'wip', 'priority' => 1], ['task_id' => 4, 'status' => 'finished', 'priority' => 3], ], [foreign_id_key => 'task_id']);
Result is the same as the result of the sync method of BelongsToMany, an array with attach, detached and updated rows.
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
Please see SECURITY for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
Treeware
You're free to use this package, but if it makes it to your production environment we would highly appreciate you buying or planting the world a tree.
It’s now common knowledge that one of the best tools to tackle the climate crisis and keep our temperatures from rising above 1.5C is to plant trees. If you contribute to my forest you’ll be creating employment for local families and restoring wildlife habitats.
You can buy trees at https://offset.earth/treeware
Read more about Treeware at https://treeware.earth
This package was generated using the Laravel Package Boilerplate.
统计信息
- 总下载量: 447
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-03-04