public static function boot() { parent::boot(); Widget::saved(function ($widget) { \Cache::tags('widgets')->flush(); }); }
public static function extract_unit($string, $start, $end) { $regexp = '/' . $start . '(.*)' . $end . '/Ui'; preg_match_all($regexp, $string, $out, PREG_PATTERN_ORDER); $unit = $out[1]; $result = []; foreach ($unit as $widget) { $split = explode(':', $widget); $db_widget = WidgetModel::find($split[1]); if ($db_widget) { if ($db_widget->path) { if (View::exists($db_widget->path)) { $result[$widget] = view($db_widget->path); } } else { $result[$widget] = str_replace('{{url}}', \Request::url(), $db_widget->content); } } else { $result[$widget] = ''; } } return $result; }