-
src/Screen/CanSee.php
Open in GitHubtrait CanSee { private $display = true; public function canSee(bool $value): self { $this->display = $value; return $this; } public function isSee(): bool { return $this->display; } }
-
src/Screen/Cell.php
Open in GitHubuse Closure; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Str; use Illuminate\Support\Traits\Macroable; use Orchid\Support\Blade; abstract class Cell { use Macroable, CanSee; protected $name; protected $title; protected $render; protected $column; protected $popover; public function __construct(string $name) { $this->name = $name; $this->column = $name; } public static function make(string $name = '', string $title = null): self { $td = new static($name); $td->column = $name; $td->title = $title ?? Str::title($name); return $td; } public function render(\Closure $closure): self { $this->render = $closure; return $this; } public function popover(string $text): self { $this->popover = $text; return $this; } public function component(string $component, string $name = null, array $params = []): self { return $this->render(function ($value) use ($component, $name, $params) { if ($name === null) { return Blade::renderComponent($component, $value); } $params[$name] = $value; return Blade::renderComponent($component, $params); }); } protected function handler($source) { return with($source, $this->render); } }