{"id":37261974,"url":"https://github.com/mlk9/dual-response","last_synced_at":"2026-01-15T23:13:54.450Z","repository":{"id":57018177,"uuid":"468599015","full_name":"mlk9/dual-response","owner":"mlk9","description":"With this package, you can operate your API and web in a single controller. (Laravel Package)","archived":false,"fork":false,"pushed_at":"2022-08-02T17:03:40.000Z","size":45,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-14T13:54:33.368Z","etag":null,"topics":["api-rest","controllers","laravel","laravel-package"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mlk9.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-11T03:48:59.000Z","updated_at":"2022-03-12T15:17:38.000Z","dependencies_parsed_at":"2022-08-22T11:31:39.724Z","dependency_job_id":null,"html_url":"https://github.com/mlk9/dual-response","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/mlk9/dual-response","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlk9%2Fdual-response","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlk9%2Fdual-response/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlk9%2Fdual-response/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlk9%2Fdual-response/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mlk9","download_url":"https://codeload.github.com/mlk9/dual-response/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mlk9%2Fdual-response/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28473974,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-15T22:27:41.514Z","status":"ssl_error","status_checked_at":"2026-01-15T21:54:47.910Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["api-rest","controllers","laravel","laravel-package"],"created_at":"2026-01-15T23:13:53.991Z","updated_at":"2026-01-15T23:13:54.443Z","avatar_url":"https://github.com/mlk9.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://repository-images.githubusercontent.com/468599015/5e6fd72f-0043-44c2-b968-12717fb40bf7\" /\u003e\n\n# Dual Response\nWith this package, you can operate your API and web in a single controller. (Laravel 6\u003e=)\n--\nبا این پکیج می توانید پاسخ های متفاوتی هنگامی که در روت api یا web می فرستید دریافت کنید.\n# Installation via composer\n```sh\n$ composer require mlk9/dual-response\n```\nthen publish vendor\n```sh\n$ php artisan vendor:publish --tag=dual-response\n```\n# Documents\n\n## Example for usage\nresponse($webRoute //your response, $apiRoute //your json response)\n\nBookController.php\n```sh\nuse Mlk9\\DualResponse\\Facades\\DualRes; \n...\n\n\n/**\n * Display a listing of the resource.\n *\n * @return \\Illuminate\\Http\\Response\n */\npublic function index()\n{\n  $books = Book::paginate(40);\n  return DualRes::response(view('book.index',compact('books')),['data' =\u003e $books]);\n}\n\n\n```\nYou can change default values with pass array\n## Default Response Api\n```sh\n'status_result' =\u003e true,\n'status_code' =\u003e 200,\n'message' =\u003e __('dualres.request_successful'),\n'errors' =\u003e null, //removes when don't have any errors\n'data' =\u003e null, //removes when don't have any data\n'current_time' =\u003e now()-\u003etimestamp,\n```\n## Default Response When you pass to key `error`\nIn api routes :\n```sh\n'status_result' =\u003e false,\n'status_code' =\u003e 400,\n'message' =\u003e __('dualres.request_not_valid'),\n'errors' =\u003e [//your errors],\n'current_time' =\u003e now()-\u003etimestamp,\n```\nIn web routes return your response.\n## Default Response When you pass to key `data`\nIn api routes :\n```sh\n'status_result' =\u003e true,\n'status_code' =\u003e 200,\n'message' =\u003e __('dualres.request_successful'),\n'data' =\u003e [//your data],\n'current_time' =\u003e now()-\u003etimestamp,\n```\nIn web routes return your response.\n## Default Response When you pass null to key `data` (not found - 404)\nIn api routes :\n```sh\n'status_result' =\u003e false,\n'status_code' =\u003e 404,\n'message' =\u003e __('dualres.not_found'),\n'current_time' =\u003e now()-\u003etimestamp,\n```\nIn web routes abort 404 error.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlk9%2Fdual-response","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmlk9%2Fdual-response","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmlk9%2Fdual-response/lists"}