| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentForm\App\Models; |
| 4 |
|
| 5 |
use DateTimeInterface; |
| 6 |
use FluentForm\Framework\Database\Orm\Model as BaseModel; |
| 7 |
|
| 8 |
class Model extends BaseModel |
| 9 |
{ |
| 10 |
/** |
| 11 |
* The attributes that aren't mass assignable. |
| 12 |
* |
| 13 |
* @var array |
| 14 |
*/ |
| 15 |
protected $guarded = ['id', 'ID']; |
| 16 |
|
| 17 |
/** |
| 18 |
* Serialize dates to Y-m-d H:i:s format for backward compatibility. |
| 19 |
* |
| 20 |
* The framework v2 defaults to ISO 8601 (e.g. 2026-03-03T08:54:40+00:00) |
| 21 |
* but existing JS code expects the simple Y-m-d H:i:s format. |
| 22 |
* |
| 23 |
* @param DateTimeInterface $date |
| 24 |
* @return string |
| 25 |
*/ |
| 26 |
protected function serializeDate(DateTimeInterface $date) |
| 27 |
{ |
| 28 |
return $date->format('Y-m-d H:i:s'); |
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* Get the number of models to return per page. |
| 33 |
* |
| 34 |
* @return int |
| 35 |
*/ |
| 36 |
public function getPerPage() |
| 37 |
{ |
| 38 |
$request = wpFluentForm('request'); |
| 39 |
|
| 40 |
return intval( |
| 41 |
$request->get('per_page', $request->get('perPage', $this->perPage)) |
| 42 |
); |
| 43 |
} |
| 44 |
} |
| 45 |
|