承接 tasmidur/coupon 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tasmidur/coupon

最新稳定版本:v1.0.1

Composer 安装命令:

composer require tasmidur/coupon

包简介

description

README 文档

README

This package can associate coupons with your Eloquent models. This might come in handy, if you need to associate voucher codes with content that is stored in your Eloquent models.

Installation

You can install the package via composer:

composer require tasmidur/coupon

The package will automatically register itself.

You can publish the migration with:

php artisan vendor:publish --provider="Tasmidur\Coupon\LaravelCouponServiceProvider" --tag="coupon-migrations"

After the migration has been published you can create the coupons table by running the migrations:

php artisan migrate

You can publish the config-file with:

php artisan vendor:publish --provider=Tasmidur\Coupon\LaravelCouponServiceProvider --tag="config"

This is the contents of the published config file:

<?php

return [

    /*
     * Table that will be used for migration
     */
    'table' => 'coupons',

    /*
     * Model to use
     */
    'model' => \Tasmidur\Coupon\Models\Coupon::class,

    /*
     * Pivot table name for coupons and other table relation
     */
    'relation_table' => 'coupon_applied',

    /*
    * Pivot table model name for coupons and other table relation
    */

    'relation_model_class' => \App\Models\Course::class,
    /*
     * List of characters that will be used for Coupons code generation.
     */
    'coupon_mix_characters' => '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',

    /*
     * Coupons code prefix.
     *
     * Example: course2022
     * Generated Code: course2022-37JH-1PUY
     */
    'prefix' => null,

    /*
     * Coupons code suffix.
     *
     * Example: course2022
     * Generated Code: 37JH-1PUY-course2022
     */
    'suffix' => null,

    /*
     * Separator to be used between prefix, code and suffix.
     */
    'separator' => '-',

    'coupon_format'=>'*****-*****'


];

Usage

The basic concept of this package is that you can create coupons, that are associated with a specific model. For example, you could have an application that sells online video courses and a voucher would give a user access to one specific video course.

Creating coupons

Using the facade

You can create one or multiple coupons and access by using the coupons facade:

  • @method static array createCoupon(string $couponType, float $price, Carbon|null $expiredAt = null, int $totalAmount = 1)
  • @method static mixed getCouponList(string $sortBy = "id", string $orderBy = "ASC")
  • @method static mixed getCouponListWithPagination(int $length = 10, string $sortBy = "id", string $orderBy = "ASC")
  • @method static bool deleteCoupon(int $id)
  • @method static mixed getCoupon(int $id)
  • @method static mixed updateCoupon(array $payload, int $id)
  • @method static mixed check(string $code)
  • @method static mixed whereApplyCoupon(string $code)
//Use for Create
$coupon = Coupons::createCoupon(string $couponType, float $price, Carbon|null $expiredAt = null, int $totalAmount = 1);
//Use for get Coupon List
$coupon = Coupons::getCouponList(string $sortBy = "id", string $orderBy = "ASC");
$coupon = Coupons::getCouponListWithPagination(int $length = 10, string $sortBy = "id", string $orderBy = "ASC");
$coupon = Coupons::deleteCoupon(int $id);
$coupon = Coupons::getCoupon(int $id);
//Use for update Coupon List
$coupon = Coupons::updateCoupon(array $payload, int $id);
//Use for validity check of Coupon
$coupon = Coupons::check(string $code);
//return list of applied coupon where it applied
$coupon = Coupons::whereApplyCoupon(string $code);

Add the Tasmidur\Coupon\Traits\CouponTrait trait to your model. This way you can easily apply coupon codes and the package takes care of storing the coupon association in the database.

 $course = Course::findOrFail($courseId);
 /** One Coupon Is for One Course */
 $course->applyUniqueCoupon($couponCode);
 /** all applied coupons that is associated with course */
 $coupons = Course::eloquentQuery($sortBy, $orderBy, $searchValue)->with(['category', 'coupons'])->get();

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 15
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-07-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固