{"id":42896256,"url":"https://github.com/askdkc/laravel_compositekey","last_synced_at":"2026-01-30T15:11:01.133Z","repository":{"id":37588361,"uuid":"320582531","full_name":"askdkc/laravel_compositekey","owner":"askdkc","description":"Laravelで複合キーを使うサンプルコード","archived":false,"fork":false,"pushed_at":"2025-08-22T02:32:25.000Z","size":3835,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-22T04:28:01.082Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/askdkc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-12-11T13:31:31.000Z","updated_at":"2025-08-22T02:32:22.000Z","dependencies_parsed_at":"2023-02-17T10:15:50.636Z","dependency_job_id":"5b4ee8cb-d540-43d1-a306-13d4568bb711","html_url":"https://github.com/askdkc/laravel_compositekey","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/askdkc/laravel_compositekey","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/askdkc%2Flaravel_compositekey","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/askdkc%2Flaravel_compositekey/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/askdkc%2Flaravel_compositekey/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/askdkc%2Flaravel_compositekey/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/askdkc","download_url":"https://codeload.github.com/askdkc/laravel_compositekey/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/askdkc%2Flaravel_compositekey/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28914898,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-30T12:13:43.263Z","status":"ssl_error","status_checked_at":"2026-01-30T12:13:22.389Z","response_time":66,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":"2026-01-30T15:11:00.469Z","updated_at":"2026-01-30T15:11:01.123Z","avatar_url":"https://github.com/askdkc.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Compostite Prime Keyに対応したLaravel Trait\n\n## インストール\n```\ngit clone このURL お好きな名前\ncd お好きな名前\ncomposer install\ncp .env.example .env\n\nvi .env\nDB_CONNECTION=sqlite に変更\n\nphp artisan key:generate\ntouch database/database.sqlite\n\nphp artisan migrate\n\nnpm install\nnpm run dev\n```\n\n## 動作確認\n```\nphp artisan serve\n\nhttp://127.0.0.1:8000/memos にアクセスし新規データ作成\n\nID が同一かつSub IDが異なるデータを作成\n\n一覧でメモをクリックすると編集画面\n\nIDとSub IDはそのままに、メモだけ編集すると、なんということでしょう。きちんとデータ更新が可能です。\n```\n\n## 既存のDBが既にあり、それをLaravelでCRUDしたい場合\n```\n    App\\Models\\Memo.php でコメントアウトされている\n\n    use \\App\\Traits\\HasCompositeKey;\n    protected $primaryKey = ['id','subid'];\n\n    を参考に、既存のDBのPrimary Keyに合わせてご利用願います。\n\n    Primary Keyが company_id, product_id, customer_id の場合は\n\n    protected $primaryKey = ['company_id','product_id','customer_id'];\n    \n    と設定しましょう。\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faskdkc%2Flaravel_compositekey","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faskdkc%2Flaravel_compositekey","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faskdkc%2Flaravel_compositekey/lists"}