不知道我在这里缺少什么..我正在尝试将一些数据从我的应用程序发布到基于 PHP 的后端系统(Laravel 框架)。这是我的尝试和失败的详细信息:
当我的应用程序尝试 POST API 调用时,存储/日志出现错误:
[2020-08-17 07:58:43] development.ERROR: Method App\Http\Controllers\API\ProductOrderAPIController::store does not exist. {"userId":74,"exception":"[object] (BadMethodCallException(code: 0): Method App\\Http\\Controllers\\API\\ProductOrderAPIController::store does not exist. at /home2/vegans/public_html/shopcontrol/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:68) [stacktrace]
表名:
product_orders
来自 api.php :
Route::resource('product_orders', 'API\ProductOrderAPIController');
我的 ProductOrderAPIController.php :
<?php
namespace App\Http\Controllers\API;
use App\Models\ProductOrder;
use App\Repositories\ProductOrderRepository;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use InfyOm\Generator\Criteria\LimitOffsetCriteria;
use Prettus\Repository\Criteria\RequestCriteria;
use Illuminate\Support\Facades\Response;
use Prettus\Repository\Exceptions\RepositoryException;
use Flash;
/**
* Class ProductOrderController
* @package App\Http\Controllers\API
*/
class ProductOrderAPIController extends Controller
{
/** @var ProductOrderRepository */
private $productOrderRepository;
public function __construct(ProductOrderRepository $productOrderRepo)
{
$this->productOrderRepository = $productOrderRepo;
}
public function index(Request $request)
{
try{
$this->productOrderRepository->pushCriteria(new RequestCriteria($request));
$this->productOrderRepository->pushCriteria(new LimitOffsetCriteria($request));
} catch (RepositoryException $e) {
Flash::error($e->getMessage());
}
$productOrders = $this->productOrderRepository->all();
return $this->sendResponse($productOrders->toArray(), 'Product Orders retrieved successfully');
}
牛魔王的故事
斯蒂芬大帝