update biface local
This commit is contained in:
82
models/ListManagement.php
Normal file
82
models/ListManagement.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace app\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "list_management".
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $type
|
||||
* @property string $name
|
||||
* @property string $image
|
||||
* @property string $gender
|
||||
* @property int $birthday
|
||||
* @property string $telephone
|
||||
* @property string $address
|
||||
* @property int $time
|
||||
*/
|
||||
class ListManagement extends \yii\db\ActiveRecord {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName() {
|
||||
return 'list_management';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules() {
|
||||
return [
|
||||
[['type', 'name', 'gender', 'telephone', 'address', 'image'], 'string'],
|
||||
[['birthday', 'time'], 'integer'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels() {
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'type' => 'Type',
|
||||
'name' => 'Name',
|
||||
'image' => 'Registration Image',
|
||||
'gender' => 'Gender',
|
||||
'birthday' => 'Birthday',
|
||||
'telephone' => 'Telephone',
|
||||
'address' => 'Address',
|
||||
'time' => 'Registration time'
|
||||
];
|
||||
}
|
||||
|
||||
public function create($data) {
|
||||
$r = $this->load([
|
||||
'type' => $data['type'],
|
||||
'name' => $data['name'],
|
||||
'image' => $data['image'],
|
||||
'gender' => $data['gender'],
|
||||
'birthday' => $data['birthday'] === "" ? 0 : date_format(date_create_from_format('d/m/Y', $data['birthday']), 'U'),
|
||||
'telephone' => $data['telephone'],
|
||||
'address' => $data['address'],
|
||||
'time' => time()
|
||||
], '');
|
||||
if ($r) {
|
||||
try {
|
||||
$this->save();
|
||||
return $this->id;
|
||||
} catch (\Exception $ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static $typeArray = [
|
||||
"wl" => "Whitelist",
|
||||
"bl" => "Blacklist"
|
||||
];
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user