-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #374 from karlomikus/develop
Skip ENV for meilisearch setup
- Loading branch information
Showing
12 changed files
with
115 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ public function rules() | |
Rule::enum(BarStatusEnum::class), | ||
'nullable', | ||
], | ||
'images' => 'array|max:1', | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Kami\Cocktail\Services; | ||
|
||
use Meilisearch\Client; | ||
use Meilisearch\Endpoints\Keys; | ||
|
||
final class MeilisearchService | ||
{ | ||
private bool $isNewMeilisearchKey; | ||
|
||
public function __construct(private readonly Client $client) | ||
{ | ||
} | ||
|
||
public function isNewMeilisearchKey(): bool | ||
{ | ||
return $this->isNewMeilisearchKey; | ||
} | ||
|
||
public function getSearchAPIKey(): Keys | ||
{ | ||
$searchApiKey = null; | ||
|
||
$keys = $this->client->getKeys(); | ||
/** @var \Meilisearch\Endpoints\Keys */ | ||
foreach ($keys->getResults() as $key) { | ||
if ($key->getName() === 'bar-assistant') { | ||
$this->isNewMeilisearchKey = false; | ||
$searchApiKey = $key; | ||
} | ||
} | ||
|
||
if (!$searchApiKey) { | ||
$this->isNewMeilisearchKey = true; | ||
$searchApiKey = $this->client->createKey([ | ||
'actions' => ['search'], | ||
'indexes' => ['cocktails', 'ingredients'], | ||
'expiresAt' => null, | ||
'name' => 'bar-assistant', | ||
'description' => 'Client key generated by Bar Assistant Server. Key for accessing cocktails and ingredients indexes.' | ||
]); | ||
} | ||
|
||
return $searchApiKey; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters