Laravel :有人知道如何从数据库中获取 api 吗?
Laravel : Anyone know how to foreach api from database?
我是 laravel
的新手
我的 Tiktoks 数据库中有这些数据 table :
Id
Username
1
Example
我的控制器上有这个
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Tiktok;
class DashboardController extends Controller
{
public function index(Request $request)
{
$ttapi = new \Sovit\TikTok\Api(array());
$username = Tiktok::select(['username'])
->get()
->toArray();
$userinfo = $ttapi->getUser($username);
return view('admin.dashboard.index', compact(['userinfo']));
}
}
如果您在 $userinfo
中看到我有 $ttapi->getUser
,我如何使用来自 Tiktoks table 的 1 个数据来获取每个数据?
只需从您的代码中删除 ->toArray()
我是 laravel
的新手我的 Tiktoks 数据库中有这些数据 table :
Id | Username |
---|---|
1 | Example |
我的控制器上有这个
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Tiktok;
class DashboardController extends Controller
{
public function index(Request $request)
{
$ttapi = new \Sovit\TikTok\Api(array());
$username = Tiktok::select(['username'])
->get()
->toArray();
$userinfo = $ttapi->getUser($username);
return view('admin.dashboard.index', compact(['userinfo']));
}
}
如果您在 $userinfo
中看到我有 $ttapi->getUser
,我如何使用来自 Tiktoks table 的 1 个数据来获取每个数据?
只需从您的代码中删除 ->toArray()