PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / 1.5.1
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution v1.5.1
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 / Model.php

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

59 lines 1.4 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\Framework\Database\Orm\Model as BaseModel;
6
7 class Model extends BaseModel
8 {
9 public function __construct($attributes = [])
10 {
11 parent::__construct($attributes);
12 }
13
14 public function scopeLatest($query, $field = 'created_at')
15 {
16 return $query->orderBy($field, 'DESC');
17 }
18
19 public function scopeNewest($query, $field = 'created_at')
20 {
21 return $query->orderBy($field, 'ASC');
22 }
23
24 public function getPerPage()
25 {
26 return (isset($_REQUEST['per_page'])) ? intval($_REQUEST['per_page']) : 15; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
27 }
28
29 /**
30 * Get a fresh timestamp for the model.
31 *
32 * @return \DateTime
33 */
34 public function freshTimestamp()
35 {
36 return new \DateTime(gmdate('Y-m-d H:i:s')); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
37 }
38
39 public function getTimezone()
40 {
41 return new \DateTimeZone('UTC');
42 }
43
44 /**
45 * Determine if the new and old values for a given key are numerically equivalent.
46 *
47 * @param string $key
48 * @return bool
49 */
50 protected function originalIsNumericallyEquivalent($key)
51 {
52 $current = $this->attributes[$key];
53
54 $original = $this->original[$key];
55
56 return is_numeric($current) && is_numeric($original) && strcmp((string) $current, (string) $original) === 0;
57 }
58 }
59