小编Ali*_*ahi的帖子

如何编写自己的DD()函数与laravel相同?

我使用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)

它运作良好,但我需要有风格和有组织的列表形式.

可能吗 ?

php wordpress var-dump laravel

8
推荐指数
5
解决办法
3万
查看次数

在laravel处理两个独立的ajaxes的最佳方法是什么?

所以我有一个页面有两个单独的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中的选项

所以这是我的问题,有没有更好的方法来做到这一点? 在此输入图像描述 (左边的选择框是第二个ajax

javascript ajax laravel

5
推荐指数
1
解决办法
106
查看次数

Mysql 函数 CONTAINS 和 GEOMFROMTEXT 不起作用

所以我有这个包含来自 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)

mysql

4
推荐指数
1
解决办法
1887
查看次数

连接被拒绝 [tcp://127.0.0.1:6379] Laravel 5.6

我一直在努力在我的系统上启动 redis,我得到的只是连接被拒绝!我试过: config/database ,在 127.0.0.1 和 localhost 之间切换......那么我该怎么做才能让它工作?注意:我正在使用 laradock 并且其他软件包工作正常

redis laravel-5.6

2
推荐指数
1
解决办法
7431
查看次数

标签 统计

laravel ×2

ajax ×1

javascript ×1

laravel-5.6 ×1

mysql ×1

php ×1

redis ×1

var-dump ×1

wordpress ×1