PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.1
Booktics – Appointment Booking Calendar for Service Businesses v1.0.1
1.0.29 1.0.28 1.0.27 1.0.26 1.0.25 1.0.24 1.0.23 1.0.22 1.0.21 1.0.20 1.0.19 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.2 1.0.3 All 31 releases
booktics / core / dummy-data / dummy-data-manager.php

dummy-data-manager.php in Booktics – Appointment Booking Calendar for Service Businesses 1.0.1, at core/dummy-data/dummy-data-manager.php

87 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Booktics\Dummy_Data;
4
5 use Booktics\Models\Service_Model;
6 use Exception;
7
8 class Dummy_Data_Manager {
9 private $generator;
10
11 public function __construct() {
12 $this->generator = new Generator();
13 }
14
15 /**
16 * Generate dummy data for onboarding
17 */
18 public function generate_onboarding_data( $service_count = 3 ) {
19 $result = $this->create_services( $service_count );
20 if ( empty( $result['service_ids'] ) ) {
21 return false;
22 }
23
24 return array(
25 'services' => $result['service_ids'],
26 'errors' => $result['errors'],
27 );
28 }
29
30 /**
31 * Create fake services
32 *
33 * @param int $count Number of services to create
34 *
35 * @return array Created service IDs
36 */
37 public function create_services( int $count = 3 ): array {
38 $result = array(
39 'service_ids' => array(),
40 'errors' => array(),
41 );
42 $current_services = Service_Model::paginate();
43 if ( $current_services['total'] > 0 ) {
44 return $result;
45 }
46
47 $service_model = new \Booktics\Models\Service_Model();
48 $service_ids = array();
49 $service_types = array(
50 'Consultation' => 30,
51 'Check-up' => 60,
52 'Therapy' => 45,
53 'Examination' => 90,
54 'Follow-up' => 20,
55 'Massage' => 60,
56 'Treatment' => 45,
57 'Evaluation' => 30,
58 );
59
60 for ( $i = 0; $i < $count; $i++ ) {
61 $service_name = $this->generator->random_element( array_keys( $service_types ) );
62 $duration = $service_types[ $service_name ];
63 $description = $this->generator->sentence( 7 );
64 $service_data = array(
65 'title' => $service_name,
66 'description' => $description,
67 'content' => $description,
68 'duration_time' => $duration,
69 'duration_unit' => 'minutes',
70 'charge_amount' => $this->generator->number_between( 50, 300 ),
71 'status' => 'active',
72 );
73
74 try {
75 $service_id = $service_model->create( $service_data );
76 if ( $service_id ) {
77 $result['service_ids'][] = $service_id;
78 }
79 } catch ( Exception $e ) {
80 $result['errors'][] = 'Failed to create service: ' . $e->getMessage();
81 }
82 }
83
84 return $result;
85 }
86 }
87