update manage schedule
This commit is contained in:
@@ -179,4 +179,8 @@ class ListManagement extends \yii\db\ActiveRecord {
|
||||
];
|
||||
}
|
||||
|
||||
public function getSchedule() {
|
||||
return Schedule::find()->andWhere(['staff_id' => $this->id])->all();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
76
models/Schedule.php
Normal file
76
models/Schedule.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user