Files
api/common/classes/Model.php

32 lines
816 B
PHP

<?php
namespace Model;
class Model {
protected function ConvertToDateTime(&$field) {
if($field) {
$field = new \DateTime($field);
if($field === false || $field->getTimestamp() == 0) {
$field = null;
}
}
}
public function __construct($data) {
$class = get_class($this);
foreach($data as $key => $val) {
if(property_exists($class, $key)) {
$this->$key = $val;
}
}
}
public function url_slug($text) {
$text = strtolower($text);
$text = preg_replace('/\b([a-z]{1,3})\b/u', '', $text);
$text = preg_replace('/[^\w_\+\s]/', '', $text);
$text = preg_replace('/\s+/', '-', $text);
return trim(strtolower($text), '-');
}
}