The requested controller is like this:
public function update(Request $request, $id)
{
$goods = Goods::findOrFail($id);
$amount = $request->get('amount');
switch ($amount) {
case 10:
$price = Price::findOrFail(1);
break;
case 20:
$price = Price::findOrFail(2);
break;
case 30:
$price = Price::findOrFail(3);
break;
default:
$price = Price::findOrFail(4);
break;
}
$goods->price = $price->price;
return $price;
}
return $price;
will report an error like this:
AlgoliaException in Client.php line 748:
Hosts unreachable: Connection timed out after 2000 milliseconds,Could not resolve host: L73SHQWTEB-1.algolianet.com,Could not resolve host: L73SHQWTEB-3.algolianet.com,Could not resolve host: L73SHQWTEB-2.algolianet.com
This is an ajax patch request. The dd() test can return data normally. The following test return $goods;
can also return data normally:
public function update(Request $request, $id)
{
$goods = Goods::findOrFail($id);
return $goods;
}
Supplement:
Algolia is used in the Goods model, $goods->price = $price->price;
will trigger a query on the goods table, so the query will go to algolia Query in the index database.
class Goods extends Model
{
use Searchable;//使用algoliasearch-laravel要加上这一句,把这一句注释掉测试,即可正常工作,可是这里需要保留
}
But here we need to query the local database, how to change it?
Have you used the services provided by Algolia? If not, please check which Package introduced the
algolia/algoliasearch-laravel
dependencyUse
composer show --installed
to checkIt seems that the problem is caused by this Package https://github.com/algolia/al...
update:
You can check out this issues: https://github.com/algolia/al...