This commit is contained in:
Mekan1206
2026-05-19 21:22:36 +05:00
parent b1a6c12a00
commit e66ce8fdcd
21 changed files with 677 additions and 150 deletions

View File

@@ -0,0 +1,26 @@
<?php
namespace Database\Factories;
use App\Models\Coupon;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends Factory<Coupon>
*/
class CouponFactory extends Factory
{
protected $model = Coupon::class;
/**
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'phone' => '6'.fake()->unique()->numerify('#######'),
'code' => random_int(1, 9).'_'.Str::upper(Str::random(4)),
];
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace Database\Factories;
use App\Models\PhoneVerification;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
/**
* @extends Factory<PhoneVerification>
*/
class PhoneVerificationFactory extends Factory
{
protected $model = PhoneVerification::class;
/**
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'phone' => '6'.fake()->unique()->numerify('#######'),
'otp' => Hash::make('1234'),
'expires_at' => now()->addMinutes(10),
'verified' => false,
];
}
public function expired(): static
{
return $this->state(fn (array $attributes) => [
'expires_at' => now()->subMinute(),
]);
}
public function withOtp(string $otp): static
{
return $this->state(fn (array $attributes) => [
'otp' => Hash::make($otp),
]);
}
}