Viewing file: CustomerSeeder.php (6.9 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
namespace Database\Seeders;
use App\Models\BecameReseller; use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; use App\Models\Customer; use App\Models\CustomerSettings; use App\Models\Label; use App\Models\Plan; use App\Models\Wallet; use Carbon\Carbon;
class CustomerSeeder extends Seeder { /** * Run the database seeds. */ public function run(): void {
$customer = Customer::create([ 'first_name' => 'Devin', 'last_name' => 'Luice', 'admin_id' => 1, 'email' => 'customer@demo.com', 'password' => bcrypt('123456'), 'type' => 'normal', 'remember_token' => null, 'created_at' => now(), 'updated_at' => now(), 'deleted_at' => null, ]);
$setting = new CustomerSettings(); $setting->customer_id = $customer->id; $setting->name = 'email_notification'; $setting->value = 'true'; $setting->save();
$setting = new CustomerSettings(); $setting->customer_id = $customer->id; $setting->name = 'payment_gateway'; $setting->value = json_encode(['paypal']); $setting->save();
$label = new Label(); $label->title='new'; $label->customer_id=$customer->id; $label->color='red'; $label->status='active'; $label->save();
$wallet= new Wallet(); $wallet->customer_id=$customer->id; $wallet->credit=0; $wallet->status='approved'; $wallet->save();
$plan = Plan::first(); if ($plan->recurring_type == 'weekly') { $time = \Illuminate\Support\Carbon::now()->addWeek(); } else if ($plan->recurring_type == 'monthly') { $time = Carbon::now()->addMonth(); } else if ($plan->recurring_type == 'yearly') { $time = Carbon::now()->addYear(); } else if ($plan->recurring_type == 'custom') { $date = json_decode($plan->custom_date); $time = isset($date->from) ? new \DateTime($date->from) : ''; }
$customer->plan()->create([ 'is_current' => 'yes', 'status' => 'accepted','price' => $plan->price, 'expire_date' => $time, 'plan_id' => $plan->id, 'sms_sending_limit' => $plan->sms_sending_limit, 'max_contact' => $plan->max_contact, 'contact_group_limit' => $plan->contact_group_limit, 'sms_unit_price' => $plan->sms_unit_price, 'free_sms_credit' => $plan->free_sms_credit, 'coverage_ids' => $plan->coverage_ids, 'api_availability' => $plan->api_availability, 'sender_id_verification' => $plan->sender_id_verification, 'unlimited_sms_send' => $plan->unlimited_sms_send, 'unlimited_contact' => $plan->unlimited_contact, 'unlimited_contact_group' => $plan->unlimited_contact_group, 'dlt' => $plan->dlt ]);
$wallet->credit=$plan->free_sms_credit; $wallet->save();
$reseller = Customer::create([ 'first_name' => 'Andree', 'last_name' => 'Flick', 'admin_id' => 1, 'email' => 'reseller@demo.com', 'password' => bcrypt('123456'), 'type' => 'reseller', 'remember_token' => null, 'created_at' => now(), 'updated_at' => now(), 'deleted_at' => null, ]);
$setting = new CustomerSettings(); $setting->customer_id = $reseller->id; $setting->name = 'email_notification'; $setting->value = 'true'; $setting->save();
$setting = new CustomerSettings(); $setting->customer_id = $reseller->id; $setting->name = 'payment_gateway'; $setting->value = json_encode(['paypal']); $setting->save();
$reseller_label = new Label(); $reseller_label->title='new'; $reseller_label->customer_id=$reseller->id; $reseller_label->color='red'; $reseller_label->status='active'; $reseller_label->save();
$reseller_wallet = new Wallet(); $reseller_wallet->customer_id=$reseller->id; $reseller_wallet->credit=0; $reseller_wallet->status='approved'; $reseller_wallet->save();
$reseller_plan = Plan::where('plan_type', 'reseller')->first();
if ($reseller_plan->recurring_type == 'weekly') { $expire_date = \Illuminate\Support\Carbon::now()->addWeek(); } else if ($reseller_plan->recurring_type == 'monthly') { $expire_date = Carbon::now()->addMonth(); } else if ($reseller_plan->recurring_type == 'yearly') { $expire_date = Carbon::now()->addYear(); } else if ($reseller_plan->recurring_type == 'custom') { $expire_date = json_decode($reseller_plan->custom_date); $expire_date = isset($expire_date->from) ? new \DateTime($expire_date->from) : ''; }
$reseller->plan()->create([ 'is_current' => 'yes', 'status' => 'accepted', 'price' => $reseller_plan->price, 'expire_date' => $expire_date, 'plan_id' => $reseller_plan->id, 'sms_sending_limit' => $reseller_plan->sms_sending_limit, 'max_contact' => $reseller_plan->max_contact, 'contact_group_limit' => $reseller_plan->contact_group_limit, 'sms_unit_price' => $reseller_plan->sms_unit_price, 'free_sms_credit' => $reseller_plan->free_sms_credit, 'coverage_ids' => $reseller_plan->coverage_ids, 'api_availability' => $reseller_plan->api_availability, 'sender_id_verification' => $reseller_plan->sender_id_verification, 'unlimited_sms_send' => $reseller_plan->unlimited_sms_send, 'unlimited_contact' => $reseller_plan->unlimited_contact, 'unlimited_contact_group' => $reseller_plan->unlimited_contact_group, 'dlt' => $reseller_plan->dlt ?? '', ]);
BecameReseller::create([ 'customer_id' => $reseller->id, 'address' => '123 Main Street', 'country' => 'USA', 'city' => 'New York', 'zip_code' => '10001', 'documents' => json_encode([ 'passport' => 'passport.pdf', 'id_card' => 'id_card.pdf', ]), 'status' => 'approved', 'reason' => '', 'created_at' => now(), 'updated_at' => now(), ]);
} }
|