BiFace_Server_Lite/models/Schedule.php
2022-09-26 09:43:12 +07:00

77 lines
1.8 KiB
PHP

<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "schedule".
*
* @property int $id
* @property string $staff_id
* @property string $from_time
* @property string $to_time
* @property string $from_date
* @property string $to_date
* @property string $date_of_week
*/
class Schedule extends \yii\db\ActiveRecord {
/**
* {@inheritdoc}
*/
public static function tableName() {
return 'schedule';
}
/**
* {@inheritdoc}
*/
public function rules() {
return [
[['staff_id', 'from_time', 'to_time', 'from_date', 'to_date', 'date_of_week'], 'string'],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels() {
return [
'id' => 'ID',
'staff_id' => 'Staff ID',
'from_time' => 'From Time',
'to_time' => 'To Time',
'from_date' => 'From Date',
'to_date' => 'To Date',
'date_of_week' => 'Date Of Week',
];
}
public function multiCreate($datas) {
$field = ['staff_id', 'from_time', 'to_time', 'from_date', 'to_date', 'date_of_week'];
static::getDb()->createCommand()->batchInsert($this->tableName(), $field, $datas)->execute();
return;
}
public function create($data) {
$r = $this->load([
'staff_id' => $data['staff_id'],
'from_time' => $data['from_time'],
'to_time' => $data['to_time'],
'from_date' => $data['from_date'],
'to_date' => $data['to_date'],
'date_of_week' => $data['date_of_week']
], '');
if ($r) {
try {
$this->save();
return $this->id;
} catch (\Exception $ex) {
return false;
}
}
}
}