Files
daragt-coupon/database/factories/PhoneVerificationFactory.php
Mekan1206 e66ce8fdcd good
2026-05-19 21:22:36 +05:00

43 lines
969 B
PHP

<?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),
]);
}
}