coupon code system eingeführt. coupons werden vom super admin gemanaged. coupons werden mit paddle synchronisiert und dort validiert. plus: einige mobil-optimierungen im tenant admin pwa.
This commit is contained in:
51
database/factories/CouponFactory.php
Normal file
51
database/factories/CouponFactory.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\CouponStatus;
|
||||
use App\Enums\CouponType;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Coupon>
|
||||
*/
|
||||
class CouponFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$type = $this->faker->randomElement([
|
||||
CouponType::PERCENTAGE,
|
||||
CouponType::FLAT,
|
||||
]);
|
||||
|
||||
$amount = $type === CouponType::PERCENTAGE
|
||||
? $this->faker->numberBetween(5, 40)
|
||||
: $this->faker->numberBetween(5, 150);
|
||||
|
||||
return [
|
||||
'name' => $this->faker->words(3, true),
|
||||
'code' => Str::upper(Str::random(8)),
|
||||
'type' => $type,
|
||||
'amount' => $amount,
|
||||
'currency' => $type === CouponType::PERCENTAGE ? null : 'EUR',
|
||||
'status' => CouponStatus::ACTIVE,
|
||||
'is_stackable' => false,
|
||||
'enabled_for_checkout' => true,
|
||||
'auto_apply' => false,
|
||||
'usage_limit' => 100,
|
||||
'per_customer_limit' => 1,
|
||||
'description' => $this->faker->sentence(),
|
||||
'metadata' => ['note' => 'factory'],
|
||||
'starts_at' => now()->subDay(),
|
||||
'ends_at' => now()->addMonth(),
|
||||
'paddle_discount_id' => 'dsc_'.Str::upper(Str::random(10)),
|
||||
'paddle_mode' => 'standard',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user