| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentBooking\App\Hooks\Handlers; |
| 4 |
|
| 5 |
use FluentBooking\App\Models\BookingActivity; |
| 6 |
use FluentBooking\Framework\Support\Arr; |
| 7 |
|
| 8 |
class LogHandler |
| 9 |
{ |
| 10 |
public function register() |
| 11 |
{ |
| 12 |
add_action('fluent_booking/log_booking_note', [$this, 'logBookingActivity'], 10); |
| 13 |
add_action('fluent_booking/log_booking_activity', [$this, 'logBookingActivity'], 10, 1); |
| 14 |
} |
| 15 |
|
| 16 |
public function logBookingActivity($data) |
| 17 |
{ |
| 18 |
$logData = array_filter(Arr::only($data, [ |
| 19 |
'status', |
| 20 |
'type', |
| 21 |
'title', |
| 22 |
'description', |
| 23 |
'booking_id' |
| 24 |
])); |
| 25 |
|
| 26 |
if (!$logData || empty($logData['booking_id'])) { |
| 27 |
return; |
| 28 |
} |
| 29 |
|
| 30 |
BookingActivity::create($logData); |
| 31 |
} |
| 32 |
} |
| 33 |
|