{"id":25478852,"url":"https://github.com/atiqurcode/eloquent-one-to-one","last_synced_at":"2026-05-08T13:06:44.736Z","repository":{"id":37742549,"uuid":"477982996","full_name":"AtiqurCode/Eloquent-One-to-One","owner":"AtiqurCode","description":"A short crud application On API.","archived":false,"fork":false,"pushed_at":"2022-06-22T08:42:32.000Z","size":364,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-03-05T18:21:38.743Z","etag":null,"topics":["crud-api","crud-application","eloquent","laravel","laravel-8","one-to-one"],"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/AtiqurCode.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}},"created_at":"2022-04-05T05:09:04.000Z","updated_at":"2022-04-12T10:19:05.000Z","dependencies_parsed_at":"2022-08-24T16:02:14.530Z","dependency_job_id":null,"html_url":"https://github.com/AtiqurCode/Eloquent-One-to-One","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtiqurCode%2FEloquent-One-to-One","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtiqurCode%2FEloquent-One-to-One/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtiqurCode%2FEloquent-One-to-One/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AtiqurCode%2FEloquent-One-to-One/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AtiqurCode","download_url":"https://codeload.github.com/AtiqurCode/Eloquent-One-to-One/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239493707,"owners_count":19647995,"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","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":["crud-api","crud-application","eloquent","laravel","laravel-8","one-to-one"],"created_at":"2025-02-18T14:53:52.550Z","updated_at":"2025-11-06T12:30:33.537Z","avatar_url":"https://github.com/AtiqurCode.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Read One-to-One basics \u0026 try with this code as you want\n\nGo throw **laravel documentation** \u0026 many more blog\n\nfirst you need to clone this and save **.env.example as .env** and setup your environment or just change the database configure\n\n```sh\n- DB_CONNECTION=mysql\n- DB_HOST=127.0.0.1\n- DB_PORT=3306\n- DB_DATABASE=your-database-name\n- DB_USERNAME=your-database-user-name\n- DB_PASSWORD=your-database-password(if have)\n```\n\nNow just run some command on terminal\n\n```sh\ncomposer install\nphp artisan migrate\nphp artisan serve\n```\n\nAs I have said this is One to One relationship. //Imagine part\n- Example1: A User can have one profile data but can't be multiple\n- Example2: Student can have one ID information\n- Example3: Office can have one employee profile\n\nSo I have just created Two model\n- **User**\n- **Profile**\n\nUser Model are relation with hasOne\n\n```sh\n    public function profile(){\n        return $this-\u003ehasOne(Profile::class);\n    }\n```\n\nProfile Model are relation with belongsTo\n\n```sh\n    public function user()\n    {\n        return $this-\u003ebelongsTo(User::class); \n    }\n\n    // You can save return $this-\u003ebelongsTo(User::class, 'user_id');\n    relation column name if you didn't follow the convention \n```\n\nAnd controller code are depend's on condition what I need. So you can got throw the controller method.\n\nif you have **Postman**/any software like that please import One-to-One.postman_collection.json file either call\n```sh\n- {url-of-your-app}/api/users                 --method : get     // get all user list with profile\n- {url-of-your-app}/api/users/{user}          --method : get     // get one user by id with profile\n- {url-of-your-app}/api/users                 --method : post    // insert user and profile details\n- {url-of-your-app}/api/users/{user}          --method : put     // update user details\n- {url-of-your-app}/api/users/{user}          --method : delete  // delete user and profile details\n- {url-of-your-app}/api/profile/{profile}     --method : get     // get one profile details by id\n- {url-of-your-app}/api/profile/{profile}     --method : put     // update profile details\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatiqurcode%2Feloquent-one-to-one","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatiqurcode%2Feloquent-one-to-one","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatiqurcode%2Feloquent-one-to-one/lists"}