Add SMS bulk delay configuration and validate coupon phone function

This commit is contained in:
Mekan1206
2026-06-03 20:57:54 +05:00
parent 275ee63ffb
commit c74330cfaf
18 changed files with 1637 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
<?php
namespace Database\Factories;
use App\Models\SmsCampaign;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<SmsCampaign>
*/
class SmsCampaignFactory extends Factory
{
protected $model = SmsCampaign::class;
/**
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'message' => fake()->sentence(),
'mode' => 'all',
'recipient_count' => 0,
'sent_count' => 0,
'failed_count' => 0,
'skipped_count' => 0,
'created_by' => User::factory(),
'completed_at' => null,
];
}
public function completed(): static
{
return $this->state(fn (array $attributes): array => [
'completed_at' => now(),
]);
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace Database\Factories;
use App\Enums\SmsSendStatus;
use App\Models\Coupon;
use App\Models\SmsCampaign;
use App\Models\SmsSendLog;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<SmsSendLog>
*/
class SmsSendLogFactory extends Factory
{
protected $model = SmsSendLog::class;
/**
* @return array<string, mixed>
*/
public function definition(): array
{
$campaign = SmsCampaign::factory()->create();
$coupon = Coupon::factory()->create();
return [
'sms_campaign_id' => $campaign->id,
'coupon_id' => $coupon->id,
'phone' => $coupon->phone,
'message' => $campaign->message,
'status' => SmsSendStatus::Pending,
'error_message' => null,
'attempted_at' => null,
];
}
}