File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,9 @@ public function register(): void
5353 */
5454 public function boot (): void
5555 {
56+ // Validate configuration
57+ $ this ->validateConfiguration ();
58+
5659 // Publish configuration
5760 $ this ->publishes ([
5861 __DIR__ . '/../config/encrypted-search.php ' => config_path ('encrypted-search.php ' ),
@@ -75,4 +78,35 @@ public function boot(): void
7578 // Listen for all Eloquent model events and route them through the observer
7679 Event::listen ('eloquent.*: * ' , SearchIndexObserver::class);
7780 }
81+
82+ /**
83+ * Validate package configuration at boot time.
84+ *
85+ * @return void
86+ *
87+ * @throws \InvalidArgumentException if configuration is invalid
88+ */
89+ protected function validateConfiguration (): void
90+ {
91+ // Validate Elasticsearch configuration if enabled
92+ if (config ('encrypted-search.elasticsearch.enabled ' , false )) {
93+ $ host = config ('encrypted-search.elasticsearch.host ' );
94+
95+ if (empty ($ host )) {
96+ throw new \InvalidArgumentException (
97+ 'Elasticsearch is enabled but ELASTICSEARCH_HOST is not configured. ' .
98+ 'Set it in your .env file or disable Elasticsearch mode. '
99+ );
100+ }
101+
102+ $ index = config ('encrypted-search.elasticsearch.index ' );
103+
104+ if (empty ($ index )) {
105+ throw new \InvalidArgumentException (
106+ 'Elasticsearch is enabled but ELASTICSEARCH_INDEX is not configured. ' .
107+ 'Set it in your .env file. '
108+ );
109+ }
110+ }
111+ }
78112}
You can’t perform that action at this time.
0 commit comments