Add all files

This commit is contained in:
root
2025-11-30 11:57:22 +01:00
parent 2ee51cac4f
commit 044271db3d
1476 changed files with 142544 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
<?php
namespace App\Helpers;
use Illuminate\Support\Facades\Event;
class EventHelper
{
public static function itemEvent($event, $items)
{
$eventItems = Event::dispatch($event);
// Make multidimensional array flat
$eventItems = array_reduce($eventItems, function ($carry, $item) {
// Empty array or null?
if (empty($item)) {
return $carry;
}
// Is item a multidimensional array?
if (is_array($item) && isset($item[0])) {
return array_merge($carry, $item);
}
return array_merge($carry, [$item]);
}, []);
$items = array_merge($items, $eventItems);
// Sort based on priority
usort($items, function ($a, $b) {
return ($a['priority'] ?? 0) <=> ($b['priority'] ?? 0);
});
return $items;
}
public static function renderEvent($event)
{
$eventItems = Event::dispatch($event);
// Make multidimensional array flat
$eventItems = array_reduce($eventItems, function ($carry, $item) {
// Is item a multidimensional array?
if (is_array($item) && isset($item[0])) {
return array_merge($carry, $item);
}
return array_merge($carry, [$item]);
}, []);
// Sort based on priority
usort($eventItems, function ($a, $b) {
return ($a['priority'] ?? 0) <=> ($b['priority'] ?? 0);
});
$view = '';
foreach ($eventItems as $item) {
if (isset($item['view'])) {
$view .= $item['view'];
}
}
// Now we smash them together and return it as html
return $view;
}
}