49 lines
1020 B
PHP
49 lines
1020 B
PHP
<?php
|
|
namespace app\models;
|
|
|
|
use core\base\Model;
|
|
|
|
/**
|
|
* 工位模型
|
|
*/
|
|
class Workstation extends Model
|
|
{
|
|
protected $table = 'workstation';
|
|
|
|
// 获取所有工位(按排序)
|
|
public function getAll()
|
|
{
|
|
return $this->order(['sort_order ASC'])->fetchAll();
|
|
}
|
|
|
|
// 添加工位
|
|
public function addStation($data)
|
|
{
|
|
return $this->add($data);
|
|
}
|
|
|
|
// 更新工位
|
|
public function updateStation($id, $data)
|
|
{
|
|
return $this->where(['id = :id'], [':id' => $id])->update($data);
|
|
}
|
|
|
|
// 删除工位
|
|
public function deleteStation($id)
|
|
{
|
|
return $this->delete($id);
|
|
}
|
|
|
|
// 更新排序
|
|
public function updateSort($id, $sort_order)
|
|
{
|
|
return $this->where(['id = :id'], [':id' => $id])->update(['sort_order' => $sort_order]);
|
|
}
|
|
|
|
// 根据类型获取工位
|
|
public function getByType($station_type)
|
|
{
|
|
return $this->where(['station_type = :type'], [':type' => $station_type])->fetch();
|
|
}
|
|
}
|