我使用laravel很长一段时间.目前我在wordpress上工作.我喜欢使用laravel的DD()功能.
但在wordpress中,我只能使用这些,
print_r(),
var_dump(),
var_export()....
Run Code Online (Sandbox Code Playgroud)
这些都只是扩展整个数组或对象.
但我需要laravel的扩展和关闭机制来处理数组和对象.
我使用以下作为一般dd需要,
if (!function_exists('dd')) {
function dd()
{
echo '<pre>';
array_map(function($x) {var_dump($x);}, func_get_args());
die;
}
}
Run Code Online (Sandbox Code Playgroud)
它运作良好,但我需要有风格和有组织的列表形式.
可能吗 ?
所以我有一个页面有两个单独的ajax调用(使用laravel),当第一个执行时,第二个必须运行,但第二个ajax的选项在selectbox中.这是我的解决方案(心脏不好):
public function getCategoryAjax(Request $request)
{
$product = Product::where('category_id',$request->get('category_id'))->get();
return $product;
}
public function getPriceAjax(Request $request)
{
$withPrice = Product::where('category_id',$request->get('category_id'));
if ($request->get('price') == 1){
$withPrice=$withPrice->where('min_price','<', 1000000)->get();
}elseif ($request->get('price') == 2){
$withPrice=$withPrice->where('min_price','>', 1000000)->andWhere('max_price','<',2000000)->get();
}
return $withPrice;
}
Run Code Online (Sandbox Code Playgroud)
第一个方法是第一个ajax,在第二个方法我正在做if ifif用于处理selectbox中的选项
所以我有这个包含来自 mysql 的几何函数的方法:
select *, (SELECT SUM(t_o.value) FROM tree_operations t_o WHERE t_o.operation_id = operations.id) operationTreeValue, (SELECT COUNT(t_o.id) FROM `tree_operations` t_o WHERE t_o.operation_id = operations.id) operationTreeNumber, (CASE\r WHEN operations.type = 'pieces' THEN (SELECT GROUP_CONCAT(p.name) FROM `pieces` p WHERE p.id IN (SELECT piece_id FROM `piece_row_operations` WHERE operation_id = operations.id))\r WHEN operations.type = 'rows' THEN (SELECT GROUP_CONCAT(r.number) FROM `rows` r WHERE r.id IN (SELECT row_id FROM `piece_row_operations` WHERE operation_id = operations.id))\r END) AS typeName from `operations` where operations.id IN (SELECT t_o.operation_id FROM `tree_operations` …Run Code Online (Sandbox Code Playgroud) 我一直在努力在我的系统上启动 redis,我得到的只是连接被拒绝!我试过: config/database ,在 127.0.0.1 和 localhost 之间切换......那么我该怎么做才能让它工作?注意:我正在使用 laradock 并且其他软件包工作正常
laravel ×2
ajax ×1
javascript ×1
laravel-5.6 ×1
mysql ×1
php ×1
redis ×1
var-dump ×1
wordpress ×1