【发布时间】:2019-09-10 03:37:04
【问题描述】:
这是我在控制器中的功能
public function list()
{
$customers = Customer::all();
foreach ($customers as $customer) {
$list = [
'Customer ID' => $customer->id,
'Customer Name' => $customer->full_name,
];
$lists[] = $list;
}
$collection = $this->paginate($lists, $perPage = 5, $page = null, $options = []);
return new mainCollection($collection);
}
这是我的路线
Route::get('customers/list', 'customerController@list')
当我在 PostMan 中访问 http://127.0.0.1:8000/api/customers/list 时出现错误 404 Not Found 另一条路线运作良好。 有人可以帮我吗?
【问题讨论】:
-
你能发布你的 api.php 路由文件和完整的控制器代码吗?
-
我的控制器太大了,放不下
-
检查 php artisan route:list / 仔细检查您的路线信息。另外,检查你的控制器类名和命名空间。
-
你能接受评论作为答案吗?
-
我该怎么做?