This commit is contained in:
Cüneyt Şentürk
2022-09-13 09:38:25 +03:00
parent d45305585d
commit d60c7a471b
11 changed files with 89 additions and 78 deletions

View File

@ -13,6 +13,8 @@ class Information extends Component
public const DEFAULT_TYPE = 'customer';
public const DEFAULT_PLURAL_TYPE = 'customers';
public $id;
public $document;
public $hideShow;
@ -23,22 +25,20 @@ class Information extends Component
public $placement;
public $id;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(
$document, bool $hideShow = false, string $showRoute = '', string $showDocumentRoute = '', string $placement = '', string $id = ''
string $id = '', $document, bool $hideShow = false, string $showRoute = '', string $showDocumentRoute = '', string $placement = ''
) {
$this->id = (! empty($id)) ? $id : 'tooltip-information-' . $document->id;
$this->document = $document;
$this->hideShow = $hideShow;
$this->showRoute = $this->getShowRoute($document->contact->type, $showRoute);
$this->showDocumentRoute = $this->getShowRoute($document->type, $showDocumentRoute);
$this->placement = (! empty($placement)) ? $placement : 'left';
$this->id = (! empty($id)) ? $id : 'tooltip-information-' . $document->id;
}
/**

View File

@ -1,65 +1,65 @@
<?php
namespace App\View\Components\Script;
use App\Abstracts\View\Component;
use Illuminate\Support\Js;
class Declaration extends Component
{
/** @var string */
public $kind;
/** @var array */
public $value;
public $scripts = null;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(
string $kind = 'var',array $value = []
) {
$this->kind = $kind;
$this->value = $value;
$this->scripts = $this->getScripts();
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|string
*/
public function render()
{
return view('components.script.declaration');
}
protected function getScripts()
{
$scripts = '';
foreach ($this->value as $key => $value) {
$scripts .= $this->getScript($key, $value) . "\n";
}
return $scripts;
}
protected function getScript($key, $value = null)
{
$script = $this->kind . ' ' . $key;
if (! is_null($value)) {
$script .= ' = ' . Js::from($value)->toHtml() . ';';
} else {
$script .= ' = ' . 'null;';
}
return $script;
}
}
<?php
namespace App\View\Components\Script;
use App\Abstracts\View\Component;
use Illuminate\Support\Js;
class Declaration extends Component
{
/** @var string */
public $kind;
/** @var array */
public $value;
public $scripts = null;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(
string $kind = 'var',array $value = []
) {
$this->kind = $kind;
$this->value = $value;
$this->scripts = $this->getScripts();
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|string
*/
public function render()
{
return view('components.script.declaration');
}
protected function getScripts()
{
$scripts = '';
foreach ($this->value as $key => $value) {
$scripts .= $this->getScript($key, $value) . "\n";
}
return $scripts;
}
protected function getScript($key, $value = null)
{
$script = $this->kind . ' ' . $key;
if (! is_null($value)) {
$script .= ' = ' . Js::from($value)->toHtml() . ';';
} else {
$script .= ' = ' . 'null;';
}
return $script;
}
}

View File

@ -42,7 +42,7 @@ class Actions extends Component
$actions = [];
if ($this->model && !empty($this->model->line_actions)) {
if ($this->model && ! empty($this->model->line_actions)) {
$actions = $this->model->line_actions;
}