这是我的代码:
public function getLists(Request $request)
{
$user = $request->user()->id;
$apikey = DB::table('apikey')->where('api_key', '=', $user);
if($apikey){
$mc = new MailChimp($apikey);
$mailchimp_ping = $mc->get('lists',['fields' =>
'lists.id,lists.name']);
return Response::json($mailchimp_ping, 200);
}
else
{
$errorResponse = [
'message' => 'Lists not found!',
'error' => '401'
];
return Response::json( $errorResponse);
}
}
我正在尝试根据登录的用户ID获取mailchimp列表我在哪里做错了?是我的where子句期待别的吗? 任何帮助将非常感谢!
答案 0 :(得分:2)
使用value()
方法执行查询并获取密钥。例如,如果带有键的列名为apikey
:
$apikey = DB::table('apikey')->where('api_key', $user)->value('apikey');
答案 1 :(得分:0)
就我而言,更改此错误时出现:
Route::view('/report', '/main_pages/orders_parts/report')->name('guzorishi_order_1');
到
Route::get('/report/{order_id}', function ($order_id) {... })->name('guzorishi_order_1');
但忘记了Route::view
个
重命名为Route::get