Download the PHP package abhibunt/promocodes without Composer

On this page you can find all versions of the php package abhibunt/promocodes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package promocodes

laravel-promocodes

Packagist Packagist license Scrutinizer Code Quality Build Status

Promocodes generator for Laravel 5.*. Trying to make the best package in this category. You are welcome to join the party, give me some advices :tada: and make pull requests.

laravel-promocodes

Table of Contents

What's new?

Installation

Install this package via Composer:

If you are using Laravel 5.5 or later, then installation is done. Otherwise follow the next steps.

Open config/app.php and follow steps below:

Find the providers array and add our service provider.

Find the aliases array and add our facade.

Configuration

Publish config & migration file using Artisan command:

To create table for promocodes in database run:

Configuration parameters are well documented. There is no need to describe each parameter here.

Check config/promocodes.php and read comments there if you need.

Usage

Generate as many codes as you wish and output them without saving to database.

You will get array of codes in return:

Parameters

name type description required?
$amount number Number of items to be generated NO

Create as many codes as you wish. Set reward (amount).

Attach additional data as array. Specify for how many days should this codes stay alive.

By default generated code will be multipass (several users will be able to use this code once).

They will be saved in database and you will get collection of them in return:

If you want to create code that will be used only once, here is method for you.

Parameters

name type description default required?
$amount integer Number of promocodes to generate 1 NO
$reward float Number of reward that user gets (ex: 30 - can be used as 30% sale on something) null NO
$data array Any additional information to get from promocode [] NO
$expires_in integer Number of days to keed promocode valid null NO
$quantity integer How many times can promocode be used? null NO
$is_disposable boolean If promocode is one-time use only false NO

Check if given code exists, is usable and not yet expired.

Returns Promocode object if valid, or false if not.

Parameters

name type description required?
$code string Code to be checked for validity YES

If you want to check if user tries to use promocode for second time you can call Promocodes::isSecondUsageAttempt and pass Promocode object as an argument. As an answer you will get boolean value


Redeem or apply code. Redeem is alias for apply method.

User should be authenticated to redeem code or this method will throw an exception (\Gabievi\Promocodes\Exceptions\UnauthenticatedException).

Also if authenticated user will try to apply code twice, it will throw an exception (\Gabievi\Promocodes\Exceptions\AlreadyUsedException)

Returns Promocode object if applied, or false if not.

Parameters

name type description required?
$code string Code to be applied by authenticated user YES

Get the collection of valid promotion codes.


You can immediately expire code by calling disable function. Returning boolean status of update.

Parameters

name type description required?
$code string Code to be set as invalid YES

And if you want to delete expired, or non-usable codes you can erase them.

This method will remove redundant codes from database and their relations to users.


Promocodes can be related to users

If you want to use user relation open app/User.php and make it Rewardable as in example:


Redeem or apply code are same. redeemCode is alias of applyCode

Pass promotion code you want to be applied by current user.

Example (usage of callback):

How to use additional data?

  1. Process of creation:

  2. Getting data back:

or

Testing

Finally it's here. I've written some test to keep this package healthy and stable

laravel-promocodes tests

License

laravel-promocodes is licensed under a MIT License.


All versions of promocodes with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2||^8.0
doctrine/dbal Version ^2.10||^3.0
laravel/framework Version ~5.7||~5.8||~6.0||~7.0||~8.0||~9.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package abhibunt/promocodes contains the following files

Loading the files please wait ....