![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/ts.corals.io/corals-api/Corals/core/Foundation/View/ViewBinder/ |
<?php namespace Corals\Foundation\View\ViewBinder; use Illuminate\Contracts\Events\Dispatcher; class CoralsViewBinder implements ViewBinder { /** * The event dispatcher implementation. * * @var Dispatcher */ protected $event; /** * The name of the view to bind JS variables to. * * @var string */ protected $views; /** * Create a new Laravel view binder instance. * * @param Dispatcher $event * @param string|array $views */ public function __construct(Dispatcher $event, $views) { $this->event = $event; $this->views = str_replace('/', '.', (array)$views); } /** * Bind the given JavaScript to the view. * * @param string $js */ public function bind($js) { foreach ($this->views as $view) { $this->event->listen("composing: {$view}", function () use ($js) { echo "<script>{$js}</script>"; }); } } }