Download the PHP package trexology/promocodes without Composer
On this page you can find all versions of the php package trexology/promocodes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download trexology/promocodes
More information about trexology/promocodes
Files in trexology/promocodes
Package promocodes
Short Description Promotional Codes Generator for Laravel 5.1
License MIT
Homepage https://github.com/trexology/promocodes
Informations about the package promocodes
Promocodes
Promotional Codes Generator for Laravel 5.*
Table of Contents
- Installation
- Composer
- Laravel
- Usage
- Recomendations
- Methods
- Config 'n Migration
- License
Installation
Composer
Run composer command in your terminal.
composer require trexology/promocodes
Laravel
Please read Config 'n Migration section first. It's requried to create promocodes table
Open config/app.php
and find the providers
key. Add PromocodesServiceProvider
to the array.
Find the aliases
key and add Facade
to the array.
Usage
Recomendations
Run php artisan make:model Promocode
and update app/Promocode.php
as following:
Methods
You can generate Promotional codes using generate
method.
The only parameter is amount of codes to generate.
- $amount int - number of promotional codes to be generated
This method will return array of codes with 5 element
You can generate and save codes instantly in your database using:
- $amount int - number of promotional codes to be generated
- $reward double - amount of reward of each promocodes
This will generate 5 codes and insert in your DB.
You can generate and save codes with the exact name in your database using:
- $code string - exact promotional code name to be generated
- $reward double - amount of reward of each promocodes
This will return false if code name already existed
Check code using method check
.
Method returns boolean.
- $promocode string - promotional code wich will be checked if issets
Laslty use code using method apply
.
Method returns boolean.
- $promocode string - promotional code wich will be checked if issets, and applied to current user
- $hard_check boolean - if false or null, you will get only boolean value of checked promocode. If true you will get amount of reward as double or false.
If method returns false, code was already used or it wasn't valid
Config 'n Migration
Publish Promocodes config & migration file using command:
Created file config\promocodes.php
. Inside you can change configuration as you wish.
Created migration file, now you can simply run php artisan migrate
and that's it, you will have promocodes table.
License
Promocodes is an open-sourced laravel package licensed under the MIT license
TODO
- [x] Create migration for vendor publish