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
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 "= date_format(date_create($date), $format) ?>";
});