{"id":15655011,"url":"https://github.com/cornernote/yii2-linkall","last_synced_at":"2025-09-09T21:48:21.960Z","repository":{"id":56958119,"uuid":"37726297","full_name":"cornernote/yii2-linkall","owner":"cornernote","description":"Behavior to handle saving multiple many to many related records in Yii2","archived":false,"fork":false,"pushed_at":"2017-08-07T10:04:58.000Z","size":33,"stargazers_count":25,"open_issues_count":1,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-01T14:47:08.810Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cornernote.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-19T14:28:49.000Z","updated_at":"2022-07-16T01:31:03.000Z","dependencies_parsed_at":"2022-08-21T09:50:19.259Z","dependency_job_id":null,"html_url":"https://github.com/cornernote/yii2-linkall","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/cornernote/yii2-linkall","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cornernote%2Fyii2-linkall","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cornernote%2Fyii2-linkall/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cornernote%2Fyii2-linkall/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cornernote%2Fyii2-linkall/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cornernote","download_url":"https://codeload.github.com/cornernote/yii2-linkall/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cornernote%2Fyii2-linkall/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274367715,"owners_count":25272301,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-09T02:00:10.223Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T12:55:25.411Z","updated_at":"2025-09-09T21:48:21.936Z","avatar_url":"https://github.com/cornernote.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Yii2 LinkAll\n\n[![Latest Version](https://img.shields.io/github/tag/cornernote/yii2-linkall.svg?style=flat-square\u0026label=release)](https://github.com/cornernote/yii2-linkall/tags)\n[![Software License](https://img.shields.io/badge/license-BSD-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![Build Status](https://img.shields.io/travis/cornernote/yii2-linkall/master.svg?style=flat-square)](https://travis-ci.org/cornernote/yii2-linkall)\n[![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/cornernote/yii2-linkall.svg?style=flat-square)](https://scrutinizer-ci.com/g/cornernote/yii2-linkall/code-structure)\n[![Quality Score](https://img.shields.io/scrutinizer/g/cornernote/yii2-linkall.svg?style=flat-square)](https://scrutinizer-ci.com/g/cornernote/yii2-linkall)\n[![Total Downloads](https://img.shields.io/packagist/dt/cornernote/yii2-linkall.svg?style=flat-square)](https://packagist.org/packages/cornernote/yii2-linkall)\n\nBehavior to handle saving multiple many to many related records in Yii2.\n\n## Installation\n\nThe preferred way to install this extension is through [composer](http://getcomposer.org/download/).\n\nEither run\n\n```\n$ composer require cornernote/yii2-linkall \"*\"\n```\n\nor add\n\n```\n\"cornernote/yii2-linkall\": \"*\"\n```\n\nto the `require` section of your `composer.json` file.\n\n## Usage\n\nPost Model\n\n```php\nclass Post extends ActiveRecord\n{\n    public function behaviors()\n    {\n        return [\n            \\cornernote\\linkall\\LinkAllBehavior::className(),\n        ];\n    }\n\n    public function getTags()\n    {\n        return $this-\u003ehasMany(Tag::className(), ['id' =\u003e 'tag_id'])\n            -\u003eviaTable('post_to_tag', ['post_id' =\u003e 'id']);\n            //-\u003evia('postToTag');\n    }\n}\n```\n\nTag Model\n\n```php\nclass Tag extends ActiveRecord\n{\n\n}\n```\n\nPost Controller\n\n```php\nclass PostController extends Controller\n{\n    public function actionExample()\n    {\n        $post = Post::findOne(1);\n        $tags = [Tag::findOne(2), Tag::findOne(3)];\n        \n        $extraColumns = []; // extra columns to be saved to the many to many table\n        $unlink = true; // unlink tags not in the list\n        $delete = true; // delete unlinked tags\n        \n        $post-\u003elinkAll('tags', $tags, $extraColumns, $unlink, $delete);\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcornernote%2Fyii2-linkall","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcornernote%2Fyii2-linkall","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcornernote%2Fyii2-linkall/lists"}