Pass multiple parameters to a blade directive

前端 未结 9 1738
时光说笑
时光说笑 2021-02-19 07:31

I\'m trying to create a blade directive to highlight some words that will return from my search query.

This is my blade directive:

class AppServiceProvid         


        
9条回答
  •  梦如初夏
    2021-02-19 07:43

    The value received on blade directive function is a sting, so, you must parse to get the values:

    BLADE

    @date($date, 'd-M-Y')

    AppServiceProvider

    Blade::directive('date', function ($str) {
      // $str = "$date, 'd-M-Y'";
      $data = explode(',',str_replace(' ', '', $str));
      //$data = ["$date", "'d-M-Y'"]
      $date = $data[0];
      $format = $data[1];
      return "";
    });
    

提交回复
热议问题