| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentBooking\App\Services\Integrations; |
| 4 |
|
| 5 |
use FluentBooking\App\Models\Meta; |
| 6 |
|
| 7 |
class IntegrationManagerHelper |
| 8 |
{ |
| 9 |
protected $settingsKey; |
| 10 |
protected $formId; |
| 11 |
protected $isMultiple; |
| 12 |
|
| 13 |
protected $integrationService; |
| 14 |
|
| 15 |
public function __construct($settingsKey = '', $form_id = false, $isMultiple = false) |
| 16 |
{ |
| 17 |
$this->settingsKey = $settingsKey; |
| 18 |
$this->isMultiple = $isMultiple; |
| 19 |
$this->integrationService = new CalendarIntegrationService(); |
| 20 |
} |
| 21 |
|
| 22 |
public function get($settingsId) |
| 23 |
{ |
| 24 |
$settings = Meta::where('form_id', $this->formId) |
| 25 |
->where('meta_key', $this->settingsKey) |
| 26 |
->find($settingsId); |
| 27 |
$settings->formattedValue = $this->getFormattedValue($settings); |
| 28 |
return $settings; |
| 29 |
} |
| 30 |
|
| 31 |
public function save($settings) |
| 32 |
{ |
| 33 |
// |
| 34 |
} |
| 35 |
|
| 36 |
public function update($settingsId, $settings) |
| 37 |
{ |
| 38 |
// |
| 39 |
} |
| 40 |
|
| 41 |
public function delete($settingsId) |
| 42 |
{ |
| 43 |
Meta::where('id', $settingsId) |
| 44 |
->delete(); |
| 45 |
} |
| 46 |
|
| 47 |
public function getAll() |
| 48 |
{ |
| 49 |
return []; |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
protected function getApiResponseMessage($response, $status) |
| 54 |
{ |
| 55 |
if (is_array($response) && isset($response['message'])) { |
| 56 |
return $response['message']; |
| 57 |
} |
| 58 |
|
| 59 |
return $status; |
| 60 |
} |
| 61 |
|
| 62 |
public function getFormattedValue($setting) |
| 63 |
{ |
| 64 |
return $setting->value; |
| 65 |
} |
| 66 |
} |
| 67 |
|