{"id":24200221,"url":"https://github.com/codeboxrcodehub/coupondiscount","last_synced_at":"2025-10-09T13:09:32.116Z","repository":{"id":65059478,"uuid":"542464879","full_name":"codeboxrcodehub/coupondiscount","owner":"codeboxrcodehub","description":"A PHP/Laravel package for coupon and discount","archived":false,"fork":false,"pushed_at":"2024-05-07T04:36:16.000Z","size":33,"stargazers_count":11,"open_issues_count":1,"forks_count":6,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-19T22:51:16.918Z","etag":null,"topics":["coupon","coupon-package","coupondiscount","discount-calculation","discount-package","laravel","php"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/codeboxr/coupondiscount","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/codeboxrcodehub.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}},"created_at":"2022-09-28T07:34:33.000Z","updated_at":"2024-12-25T11:48:42.000Z","dependencies_parsed_at":"2025-01-13T20:41:48.265Z","dependency_job_id":"a68be911-cd48-40c8-a719-4372c9a58cc2","html_url":"https://github.com/codeboxrcodehub/coupondiscount","commit_stats":{"total_commits":33,"total_committers":2,"mean_commits":16.5,"dds":0.06060606060606055,"last_synced_commit":"6622e7290dcbc3b6236906a3a9cf66bc71c68b50"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/codeboxrcodehub/coupondiscount","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeboxrcodehub%2Fcoupondiscount","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeboxrcodehub%2Fcoupondiscount/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeboxrcodehub%2Fcoupondiscount/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeboxrcodehub%2Fcoupondiscount/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeboxrcodehub","download_url":"https://codeload.github.com/codeboxrcodehub/coupondiscount/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeboxrcodehub%2Fcoupondiscount/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001539,"owners_count":26083102,"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-10-09T02:00:07.460Z","response_time":59,"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":["coupon","coupon-package","coupondiscount","discount-calculation","discount-package","laravel","php"],"created_at":"2025-01-13T20:41:38.475Z","updated_at":"2025-10-09T13:09:32.081Z","avatar_url":"https://github.com/codeboxrcodehub.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eCoupon Discount php/laravel package\u003c/h1\u003e\n\u003cp align=\"center\" \u003e\n\u003cimg src=\"https://img.shields.io/packagist/dt/codeboxr/coupondiscount\"\u003e\n\u003cimg src=\"https://img.shields.io/packagist/stars/codeboxr/coupondiscount\"\u003e\n\u003c/p\u003e\n\nThis is a PHP/Laravel package for Coupon Discount. This package can be used in laravel or without laravel/php projects. You can use this package for headless/rest implementation as well as blade or regular mode development. We created this\npackage while working for a project and thought to made it release for all so that it helps. This package is available as regular php [composer package](https://packagist.org/packages/codeboxr/coupondiscount).\n\n## Requirements\n\n- PHP \u003e=7.4\n\n## Installation\n\n```bash\ncomposer require codeboxr/coupondiscount\n```\n\n## Usage\n\nIf you are using laravel this package in laravel you have to publish migration first and migrate by the following command.\n\n```bash\nphp artisan vendor:publish --provider=\"Codeboxr\\CouponDiscount\\CouponDiscountServiceProvider\"\n```\n\n```bash\nphp artisan migrate\n```\n\ncoupons and coupon_histories two db table are created.\n\n`Note:` If you are using raw PHP or other PHP framework you can have to import `copuondiscount/database/sql` SQL file manually in your database.\n\n| Action Name                                                                                    | Method                                                                                                                             | Explanation                                                                                                                                                                                                                                                                                                                       |\n| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| [Create Coupon](https://github.com/codeboxrcodehub/coupondiscount#1-create-new-coupon)         | add($array)                                                                                                                        | Create coupon code by add() method it taken a array. Array formate given below                                                                                                                                                                                                                                                    |\n| [Update Coupon](https://github.com/codeboxrcodehub/coupondiscount#2-update-coupon)             | update($array,$couponId)                                                                                                           | Coupon Update by update() method it's taken two parameter first parameter is an array and second parameter is coupon id                                                                                                                                                                                                           |\n| [Remove Coupon](https://github.com/codeboxrcodehub/coupondiscount#3-remove-coupon)             | remove($couponId)                                                                                                                  | Coupon Remove by remove() method it's taken one parameter. Parameter is Coupon id                                                                                                                                                                                                                                                 |\n| [Coupon List](https://github.com/codeboxrcodehub/coupondiscount#4-coupon-list)                 | list()                                                                                                                             | Fetch coupon list by list() method. You can chain any operation in Eluquarant after this method. For example: `list()-\u003ewhere('status',1)-\u003eget();`,`list()-\u003etake(5)-\u003eget();`,`list()-\u003efirst();` etc                                                                                                                                |\n| [Coupon Validity](https://github.com/codeboxrcodehub/coupondiscount#5-coupon-validity-check)   | validity($couponCode, float $amount, string $userId, string $deviceName = null, string $ipaddress = null, string $vendorId = null) | check coupon code validity by validity() method. It's take 6 parameter 3 parameter are required. 1st parameter is coupon code,second parameter is total amount,third parameter is user id,fourth parameter (optional) device name,fifth parameter (optional) is IP address and sixth parameter (optional) is vendor id or shop id |\n| [Coupon Apply](https://github.com/codeboxrcodehub/coupondiscount#6-coupon-apply)               | apply($array)                                                                                                                      | Apply coupon in a cart amount by apply() method. apply method taken one parameter is array, example given below                                                                                                                                                                                                                   |\n| [Coupon History List](https://github.com/codeboxrcodehub/coupondiscount#7-coupon-history-list) | history()                                                                                                                          | Fetch coupon history list by history() method. You can chain any operation in Eluquarant after this method. For example: `history()-\u003ewhere('user_id',1)-\u003eget();`,`history()-\u003etake(5)-\u003eget();`,`history()-\u003efirst();` etc                                                                                                           |\n| [Remove History](https://github.com/codeboxrcodehub/coupondiscount#8-delete-coupon-history)    | historyDelete($historyId)                                                                                                          | Coupon History Remove by historyDelete() method it's taken one parameter. Parameter is Coupon history id                                                                                                                                                                                                                          |\n\n### 1. Create new coupon\n\n`*** For Using Laravel Application`\n\n```\nuse Codeboxr\\CouponDiscount\\Facades\\Coupon;\nCoupon::add([\n    'coupon_code'       =\u003e \"\", // (required) Coupon code\n    'discount_type'     =\u003e \"\", // (required) coupon discount type. two type are accepted (1. percentage and 2. fixed)\n    'discount_amount'   =\u003e \"\", // (required) discount amount or percentage value\n    'start_date'        =\u003e \"\", // (required) coupon start date\n    'end_date'          =\u003e \"\", // (required) coupon end date\n    'status'            =\u003e \"\", // (required) two status are accepted. (for active 1 and for inactive 0)\n    'minimum_spend'     =\u003e \"\", // (optional) for apply this coupon minimum spend amount. if set empty then it's take unlimited\n    'maximum_spend'     =\u003e \"\", // (optional) for apply this coupon maximum spend amount. if set empty then it's take unlimited\n    'use_limit'         =\u003e \"\", // (optional) how many times are use this coupon. if set empty then it's take unlimited\n    'use_same_ip_limit' =\u003e \"\", // (optional) how many times are use this coupon in same ip address. if set empty then it's take unlimited\n    'user_limit'        =\u003e \"\", // (optional) how many times are use this coupon a user. if set empty then it's take unlimited\n    'use_device'        =\u003e \"\", // (optional) This coupon can be used on any device\n    'multiple_use'      =\u003e \"\", // (optional) you can check manually by this multiple coupon code use or not\n    'vendor_id'         =\u003e \"\"  // (optional) if coupon code use specific shop or vendor\n]);\n```\n\n`*** For Using Raw php or other php framwork`\n\n```\nuse Codeboxr\\CouponDiscount\\Services\\CouponService;\n\n$copuon = new CouponService([\n    \"driver\"   =\u003e \"\", // (optional) database driver. By default it takes `mysql`\n    \"host\"     =\u003e \"\", // (optional) database host. By default it takes `localhost`\n    \"username  =\u003e \"\", // (required) database user name.\n    \"password\" =\u003e \"\"  // (required) database password,\n]);\n\n$copuon-\u003eadd([\n    'coupon_code'       =\u003e \"\", // (required) Coupon code\n    'discount_type'     =\u003e \"\", // (required) coupon discount type. two type are accepted (1. percentage and 2. fixed)\n    'discount_amount'   =\u003e \"\", // (required) discount amount or percentage value\n    'start_date'        =\u003e \"\", // (required) coupon start date\n    'end_date'          =\u003e \"\", // (required) coupon end date\n    'status'            =\u003e \"\", // (required) two status are accepted. (for active 1 and for inactive 0)\n    'minimum_spend'     =\u003e \"\", // (optional) for apply this coupon minimum spend amount. if set empty then it's take unlimited\n    'maximum_spend'     =\u003e \"\", // (optional) for apply this coupon maximum spend amount. if set empty then it's take unlimited\n    'use_limit'         =\u003e \"\", // (optional) how many times are use this coupon. if set empty then it's take unlimited\n    'use_same_ip_limit' =\u003e \"\", // (optional) how many times are use this coupon in same ip address. if set empty then it's take unlimited\n    'user_limit'        =\u003e \"\", // (optional) how many times are use this coupon a user. if set empty then it's take unlimited\n    'use_device'        =\u003e \"\", // (optional) This coupon can be used on any device\n    'multiple_use'      =\u003e \"\", // (optional) you can check manually by this multiple coupon code use or not\n    'vendor_id'         =\u003e \"\" // (optional) if coupon code use specific shop or vendor\n]);\n\n```\n\n### 2. Update coupon\n\n`*** For Using Laravel Application`\n\n```\nuse Codeboxr\\CouponDiscount\\Facades\\Coupon;\nCoupon::update([\n    'coupon_code'       =\u003e \"\", // (required) Coupon code\n    'discount_type'     =\u003e \"\", // (required) coupon discount type. two type are accepted (1. percentage and 2. fixed)\n    'discount_amount'   =\u003e \"\", // (required) discount amount or percentage value\n    'start_date'        =\u003e \"\", // (required) coupon start date\n    'end_date'          =\u003e \"\", // (required) coupon end date\n    'status'            =\u003e \"\", // (required) two status are accepted. (for active 1 and for inactive 0)\n    'minimum_spend'     =\u003e \"\", // (optional) for apply this coupon minimum spend amount. if set empty then it's take unlimited\n    'maximum_spend'     =\u003e \"\", // (optional) for apply this coupon maximum spend amount. if set empty then it's take unlimited\n    'use_limit'         =\u003e \"\", // (optional) how many times are use this coupon. if set empty then it's take unlimited\n    'use_same_ip_limit' =\u003e \"\", // (optional) how many times are use this coupon in same ip address. if set empty then it's take unlimited\n    'user_limit'        =\u003e \"\", // (optional) how many times are use this coupon a user. if set empty then it's take unlimited\n    'use_device'        =\u003e \"\", // (optional) This coupon can be used on any device\n    'multiple_use'      =\u003e \"\", // (optional) you can check manually by this multiple coupon code use or not\n    'vendor_id'         =\u003e \"\" // (optional) if coupon code use specific shop or vendor\n], $couponId);\n```\n\n`*** For Using Raw php or other php framwork`\n\n```\n$copuon-\u003eupdate([\n    'coupon_code'       =\u003e \"\", // (required) Coupon code\n    'discount_type'     =\u003e \"\", // (required) coupon discount type. two type are accepted (1. percentage and 2. fixed)\n    'discount_amount'   =\u003e \"\", // (required) discount amount or percentage value\n    'start_date'        =\u003e \"\", // (required) coupon start date\n    'end_date'          =\u003e \"\", // (required) coupon end date\n    'status'            =\u003e \"\", // (required) two status are accepted. (for active 1 and for inactive 0)\n    'minimum_spend'     =\u003e \"\", // (optional) for apply this coupon minimum spend amount. if set empty then it's take unlimited\n    'maximum_spend'     =\u003e \"\", // (optional) for apply this coupon maximum spend amount. if set empty then it's take unlimited\n    'use_limit'         =\u003e \"\", // (optional) how many times are use this coupon. if set empty then it's take unlimited\n    'use_same_ip_limit' =\u003e \"\", // (optional) how many times are use this coupon in same ip address. if set empty then it's take unlimited\n    'user_limit'        =\u003e \"\", // (optional) how many times are use this coupon a user. if set empty then it's take unlimited\n    'use_device'        =\u003e \"\", // (optional) This coupon can be used on any device\n    'multiple_use'      =\u003e \"\", // (optional) you can check manually by this multiple coupon code use or not\n    'vendor_id'         =\u003e \"\" // (optional) if coupon code use specific shop or vendor\n], $couponId);\n\n```\n\n### 3. Remove coupon\n\n`*** For Using Laravel Application`\n\n```\nuse Codeboxr\\CouponDiscount\\Facades\\Coupon;\n\nCoupon::remove($couponId)\n```\n\n`*** For Using Raw php or other php framwork`\n\n```\n$copuon-\u003eremove($couponId);\n```\n\n### 4. Coupon List\n\n`*** For Using Laravel Application`\n\n```\nuse Codeboxr\\CouponDiscount\\Facades\\Coupon;\n\nCoupon::list()-\u003eget();\n```\n\n`*** For Using Raw php or other php framwork`\n\n```\n$copuon-\u003elist()-\u003eget();\n```\n\n### 5. Coupon validity check\n\n```\nuse Codeboxr\\CouponDiscount\\Facades\\Coupon;\n\nCoupon::validity(\"CBX23\",1200,1,\"app\",\"192.168.0.1\",5);\n```\n\n`*** For Using Raw php or other php framwork`\n\n```\n$copuon-\u003evalidity(\"CBX23\",1200,1,\"app\",\"192.168.0.1\",5);\n```\n\n`note: validity() method first 3 method parameter are required others optional`\n\n### 6. Coupon apply\n\n```\nuse Codeboxr\\CouponDiscount\\Facades\\Coupon;\n\nCoupon::apply([\n    \"code\"        =\u003e \"\", // coupon code. (required)\n    \"amount\"      =\u003e \"\", // total amount to apply coupon. must be a numberic number (required)\n    \"user_id\"     =\u003e \"\", // user id (required)\n    \"order_id\"    =\u003e \"\", // order id (required)\n    \"device_name\" =\u003e \"\", // device name (optional)\n    \"ip_address\"  =\u003e \"\", // ip address (optional)\n    \"vendor_id\"   =\u003e \"\", // vendor id (optional)\n]);\n```\n\n`*** For Using Raw php or other php framwork`\n\n```\n$copuon-\u003eapply([\n    \"code\"        =\u003e \"\", // coupon code. (required)\n    \"amount\"      =\u003e \"\", // total amount to apply coupon. must be a numberic number (required)\n    \"user_id\"     =\u003e \"\", // user id (required)\n    \"order_id\"    =\u003e \"\", // order id (required)\n    \"device_name\" =\u003e \"\", // device name (optional)\n    \"ip_address\"  =\u003e \"\", // ip address (optional)\n    \"vendor_id\"   =\u003e \"\", // vendor id (optional)\n]);\n```\n\n### 7. Coupon history list\n\n`*** For Using Laravel Application`\n\n```\nuse Codeboxr\\CouponDiscount\\Facades\\Coupon;\n\nCoupon::history()-\u003eget();\n```\n\n`*** For Using Raw php or other php framwork`\n\n```\n$copuon-\u003ehistory()-\u003eget();\n```\n\n### 8. Delete coupon history\n\n`*** For Using Laravel Application`\n\n```\nuse Codeboxr\\CouponDiscount\\Facades\\Coupon;\n\nCoupon::historyDelete($historyId)\n```\n\n`*** For Using Raw php or other php framwork`\n\n```\n$copuon-\u003ehistoryDelete($historyId);\n```\n\n## Contributing\n\nContributions to the Coupon Discount package are welcome. Please note the following guidelines before submitting your pull request.\n\n- Follow [PSR-4](http://www.php-fig.org/psr/psr-4/) coding standards.\n\n## License\n\nCoupon Discount package is licensed under the [MIT License](http://opensource.org/licenses/MIT).\n\nCopyright 2023 [Codeboxr](https://codeboxr.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeboxrcodehub%2Fcoupondiscount","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeboxrcodehub%2Fcoupondiscount","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeboxrcodehub%2Fcoupondiscount/lists"}