title = $title; } protected function generateElementId() { $key = Str::random(8); return 'grid-modal-'.$this->grid->getName().$key; } protected function addRenderableModalScript(string $modalId, string $url) { $script = <<'); modal.find('.modal-body').loading(); $.ajax('{$url}').then(function (data) { modal.find('.modal-body').html(data); }); }) })(); JS; Admin::script($script); } protected function setUpRemoteRenderable(string $modalId, RemoteRenderable $renderable) { $renderable->with('key', $this->getKey()); $this->addRenderableModalScript($modalId, $renderable->getUrl()); $renderable::collectAssets(); } public function display($callback = null) { $title = $this->value ?: $this->trans('title'); if (func_num_args() == 2) { [$title, $callback] = func_get_args(); } $html = $this->value; $id = $this->generateElementId(); if ($callback instanceof \Closure) { $html = Helper::render( $callback->call($this->row, $this) ); } elseif (is_string($callback) && is_subclass_of($callback, RemoteRenderable::class)) { $html = ''; $this->setUpRemoteRenderable($id, $callback::make()); } elseif ($callback instanceof RemoteRenderable) { $html = ''; $this->setUpRemoteRenderable($id, $callback); } $title = $this->title ?: $title; return <<   {$this->value} EOT; } }