使用Excel library,如何在需要时让功能check_stuff
返回false
?截至目前,$this->check_stuff($path)
始终返回true
。请记住,我无法修改课程Excel
。
private function check_stuff($path) {
Excel::filter('chunk')->load($path)->chunk(250, function($results) {
// check something
return false;
});
return true;
}
答案 0 :(得分:2)
尝试在匿名函数中导入它:
private function check_stuff($path) {
$result = true;
Excel::filter('chunk')->load($path)->chunk(250, function($results) use (&$result) {
// check something
$result = false;
});
return $result;
}
答案 1 :(得分:0)
你试过这个吗?
private function check_stuff($path) {
return Excel::filter('chunk')->load($path)->chunk(250, function($results) {
// check something
return false;
});
}