mirror of https://github.com/4xmen/xshop.git
added auto complete for tags
parent
893ff16735
commit
01071196df
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Mpdf\Tag;
|
||||
|
||||
class TagController extends Controller
|
||||
{
|
||||
//
|
||||
|
||||
public function search($q)
|
||||
{
|
||||
|
||||
// // Check if $q contains any non-Latin characters
|
||||
// if (preg_match('/[^\x20-\x7E]/', $q)) {
|
||||
// // If it contains non-Latin characters, encode it
|
||||
// $q =trim( json_encode($q),' "');
|
||||
// }
|
||||
|
||||
// Perform the search
|
||||
$tags = \Spatie\Tags\Tag::where('name->' . config('app.locale'), 'like', '%' . $q . '%')->limit(10)->pluck('name');
|
||||
return ['OK' => true, 'data' => $tags];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue