| @@ 25-36 (lines=12) @@ | ||
| 22 | * @param null $label |
|
| 23 | * @param array $options |
|
| 24 | */ |
|
| 25 | public function __construct($path, $label = null, $options = []) |
|
| 26 | { |
|
| 27 | parent::__construct($path, $label, $options); |
|
| 28 | ||
| 29 | $this->setLoadOptionsQueryPreparer(function ($item, $query) { |
|
| 30 | $repository = app(RepositoryInterface::class); |
|
| 31 | $repository->setModel($this->getModelForOptions()); |
|
| 32 | $key = $repository->getModel()->getKeyName(); |
|
| 33 | ||
| 34 | return $query->whereIn($key, $this->getValueFromModel() ? $this->getValueFromModel() : []); |
|
| 35 | }); |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * Get Field name for search url. |
|
| @@ 22-33 (lines=12) @@ | ||
| 19 | * @param string|null $label |
|
| 20 | * @param array|Model $options |
|
| 21 | */ |
|
| 22 | public function __construct($path, $label = null, $options = []) |
|
| 23 | { |
|
| 24 | parent::__construct($path, $label); |
|
| 25 | ||
| 26 | $this->setLoadOptionsQueryPreparer(function ($item, $query) { |
|
| 27 | $repository = app(RepositoryInterface::class); |
|
| 28 | $repository->setModel($this->getModelForOptions()); |
|
| 29 | $key = $repository->getModel()->getKeyName(); |
|
| 30 | ||
| 31 | return $query->where([$key => $this->getValueFromModel()]); |
|
| 32 | }); |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * @param Router $router |
|