mirror of
https://github.com/koel/koel
synced 2024-12-23 11:03:05 +00:00
29 lines
686 B
PHP
29 lines
686 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\API\Search;
|
|
|
|
use App\Http\Controllers\API\Controller;
|
|
use App\Services\SearchService;
|
|
use Illuminate\Http\Request;
|
|
use InvalidArgumentException;
|
|
|
|
class SongSearchController extends Controller
|
|
{
|
|
private SearchService $searchService;
|
|
|
|
public function __construct(SearchService $searchService)
|
|
{
|
|
$this->searchService = $searchService;
|
|
}
|
|
|
|
public function index(Request $request)
|
|
{
|
|
if (!$request->get('q')) {
|
|
throw new InvalidArgumentException('A search query is required.');
|
|
}
|
|
|
|
return [
|
|
'songs' => $this->searchService->searchSongs($request->get('q')),
|
|
];
|
|
}
|
|
}
|