PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / trunk
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution vtrunk
2.4.0 2.3.0 2.2.5 2.2.0 2.1.2 2.1.1 trunk 1.10.0 1.10.01 1.10.02 1.5.0 1.5.01 1.5.02 1.5.1 1.5.10 1.5.20 1.5.21 1.5.22 1.5.23 1.5.24 1.5.25 1.6.0 1.7.0 1.7.1 1.7.2 All 33 releases
fluent-booking / app / Models / Availability.php

Availability.php in Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution trunk, at app/Models/Availability.php

68 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentBooking\App\Models;
4
5 use FluentBooking\App\Services\Helper;
6
7 class Availability extends Model
8 {
9 protected $table = 'fcal_meta';
10
11 protected $guarded = ['id'];
12
13 protected $fillable = [
14 'object_type',
15 'object_id',
16 'key',
17 'value'
18 ];
19
20 public static function boot()
21 {
22 parent::boot();
23
24 static::creating(function ($model) {
25 $model->object_type = 'availability';
26 });
27
28 static::updating(function ($model) {
29 $model->object_type = 'availability';
30 });
31
32 static::addGlobalScope('object_type', function ($query) {
33 $query->where('object_type', 'availability');
34 });
35 }
36
37 public function setValueAttribute($value)
38 {
39 $this->attributes['value'] = \maybe_serialize($value);
40 }
41
42 public function getValueAttribute($value)
43 {
44 return \maybe_unserialize($value);
45 }
46
47 public function getAuthor()
48 {
49 $user = get_user_by('ID', $this->object_id);
50 if(!$user) {
51 return [
52 'name' => __('Deleted user', 'fluent-booking'),
53 'avatar' => ''
54 ];
55 }
56
57 $name = trim($user->first_name . ' ' . $user->last_name);
58 if(!$name) {
59 $name = $user->display_name;
60 }
61
62 return [
63 'name' => $name,
64 'avatar' => Helper::fluentBookingUserAvatar($user->user_email, $user)
65 ];
66 }
67 }
68