2017 © Pedro Peláez
 

library promocodes

Promotional Codes Generator for Laravel 5.1

image

trexology/promocodes

Promotional Codes Generator for Laravel 5.1

  • Thursday, August 18, 2016
  • by trexology
  • Repository
  • 3 Watchers
  • 12 Stars
  • 405 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 20 Forks
  • 1 Open issues
  • 9 Versions
  • 20 % Grown

The README.md

Promocodes

PR0M0C0D35, (*1)

Latest Stable Version Total Downloads License, (*2)

Promotional Codes Generator for Laravel 5.*, (*3)

Table of Contents

Installation

Composer

Run composer command in your terminal., (*4)

composer require trexology/promocodes

Laravel

Please read Config 'n Migration section first. It's requried to create promocodes table, (*5)

Open config/app.php and find the providers key. Add PromocodesServiceProvider to the array., (*6)

Trexology\Promocodes\PromocodesServiceProvider::class

Find the aliases key and add Facade to the array., (*7)

'Promocodes' => Trexology\Promocodes\Facades\Promocodes::class

Usage

Recomendations

Run php artisan make:model Promocode and update app/Promocode.php as following:, (*8)

/**
 * @var bool
 */
public $timestamps = false;

/**
 * @var array
 */
protected $fillable = [
    'code',
    'reward',
    'quantity',
  'is_used',
];

Methods

You can generate Promotional codes using generate method., (*9)

The only parameter is amount of codes to generate., (*10)

Promocodes::generate(5); // $amount = 1
  • $amount int - number of promotional codes to be generated

This method will return array of codes with 5 element, (*11)


You can generate and save codes instantly in your database using:, (*12)

Promocodes::generateAndSave(5, 10.50); // $amount = 1, $reward = null
  • $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., (*13)


You can generate and save codes with the exact name in your database using:, (*14)

Example:

Promocodes::generateCodeName("OFF20%", 0.2); // $reward = null (percentage discount)
Promocodes::generateCodeName("5SGDOFF", 5); // $reward = null (dollar discount)
  • $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, (*15)


Check code using method check., (*16)

Method returns boolean., (*17)

$valid = Promocodes::check('TEST-CODE'); // $promocode
  • $promocode string - promotional code wich will be checked if issets

Laslty use code using method apply., (*18)

Method returns boolean., (*19)

$applied = Promocodes::apply('TEST-CODE', true); // $promocode, $hard_check = false
  • $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, (*20)

Config 'n Migration

Publish Promocodes config & migration file using command:, (*21)

php artisan vendor:publish

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., (*22)

License

Promocodes is an open-sourced laravel package licensed under the MIT license, (*23)

TODO

  • [x] Create migration for vendor publish

The Versions

18/08 2016

dev-master

9999999-dev https://github.com/trexology/promocodes

Promotional Codes Generator for Laravel 5.1

  Sources   Download

MIT

The Requires

 

by Avatar trexology

laravel php promo code coupon code discount code

18/08 2016

1.1

1.1.0.0 https://github.com/trexology/promocodes

Promotional Codes Generator for Laravel 5.1

  Sources   Download

MIT

The Requires

 

by Avatar trexology

laravel php promo code coupon code discount code

10/08 2016

1.0

1.0.0.0 https://github.com/trexology/promocodes

Promotional Codes Generator for Laravel 5.1

  Sources   Download

MIT

The Requires

 

by Avatar trexology

laravel php promo code coupon code discount code

27/05 2016

0.1.5

0.1.5.0 https://github.com/zgabievi/promocodes

Promotional Codes Generator for Laravel 5.1

  Sources   Download

MIT

The Requires

 

by Avatar zgabievi

laravel php promo code coupon code discount code

27/05 2016

0.1.4

0.1.4.0 https://github.com/zgabievi/promocodes

Promotional Codes Generator for Laravel 5.1

  Sources   Download

MIT

The Requires

 

by Avatar zgabievi

laravel php promo code coupon code discount code

20/05 2016

0.1.3

0.1.3.0 https://github.com/zgabievi/promocodes

Promotional Codes Generator for Laravel 5.1

  Sources   Download

MIT

The Requires

 

by Avatar zgabievi

laravel php promo code coupon code discount code

17/05 2016

0.1.2

0.1.2.0 https://github.com/zgabievi/promocodes

Promotional Codes Generator for Laravel 5.1

  Sources   Download

MIT

The Requires

 

by Avatar zgabievi

laravel php promo code coupon code discount code

24/11 2015

0.1.1

0.1.1.0 https://github.com/zgabievi/promocodes

Promotional Codes Generator for Laravel 5.1

  Sources   Download

MIT

The Requires

 

by Avatar zgabievi

laravel php promo code coupon code discount code

24/11 2015

0.1.0

0.1.0.0 https://github.com/zgabievi/promocodes

Promotional Codes Generator for Laravel 5.1

  Sources   Download

MIT

The Requires

 

by Avatar zgabievi

laravel php promo code coupon code discount code