【发布时间】:2021-07-07 07:12:45
【问题描述】:
我想做一个函数来获取交易代码但返回值为空。
我正在从我的模型中调用此函数。
public function getTransactionCode($type){
switch($type)
{
case '52';
$count = $this->where('type_id',$type)
->count('id');
$next = (intval($count) ?: 0) + 1;
$code = "LAP-00{$next}";
return $code;
case '53';
$count = $this->where('type_id',$type)
->count('id');
$next = (intval($count) ?: 0) + 1;
$code = "PC-00{$next}";
return $code;
case '54';
$count = $this->where('type_id',$type)
->count('id');
$next = (intval($count) ?: 0) + 1;
$code = "TAB-00{$next}";
return $code;
case '55';
$count = $this->where('type_id',$type)
->count('id');
$next = (intval($count) ?: 0) + 1;
$code = "OOE-00{$next}";
return $code;
}
}
我想在我的控制器上使用这个函数从我的模型中提取任何值。
$code = $this->equipment->getTransactionCode($type = '');
但它总是返回空值。
【问题讨论】:
标签: php laravel laravel-4 switch-statement