分享 / 0 / 4 / 创建于 5年前
laravel when方法怎么在其他框架实现啊
这个问题要问其他框架
可以将 when 方法 copy 过去
if($when){ $where['XX'] = 'XXX'; }
public function when($value, $callback, $default = null) { if ($value) { return $callback($this, $value) ?: $this; } elseif ($default) { return $default($this, $value) ?: $this; }
return $this; }
我要举报该,理由是:
这个问题要问其他框架
可以将 when 方法 copy 过去
if($when){
$where['XX'] = 'XXX';
}
public function when($value, $callback, $default = null)
{
if ($value) {
return $callback($this, $value) ?: $this;
} elseif ($default) {
return $default($this, $value) ?: $this;
}