小编Edm*_*nok的帖子

传递给GuzzleHttp\Client :: request()的参数3必须是类型数组,给定字符串

我正在试验SammyK/LaravelFacebookSdk.试图从示例中运行此行: $response = Facebook::get('/me?fields=id,name,email', 'user-access-token');

反过来运行 /var/www/vendor/facebook/php-sdk-v4/src/Facebook/HttpClients/FacebookGuzzleHttpClient.php line 61

public function send($url, $method, $body, array $headers, $timeOut)
{
    $options = [
        'headers' => $headers,
        'body' => $body,
        'timeout' => $timeOut,
        'connect_timeout' => 10,
        'verify' => __DIR__ . '/certs/DigiCertHighAssuranceEVRootCA.pem',
    ];
    $request = $this->guzzleClient->createRequest($method, $url, $options);

    try {
        $rawResponse = $this->guzzleClient->send($request);
    } catch (RequestException $e) {
        $rawResponse = $e->getResponse();

        if ($e->getPrevious() instanceof RingException || !$rawResponse instanceof ResponseInterface) {
            throw new FacebookSDKException($e->getMessage(), $e->getCode());
        }
    }

    $rawHeaders = $this->getHeadersAsString($rawResponse);
    $rawBody = $rawResponse->getBody();
    $httpStatusCode = …
Run Code Online (Sandbox Code Playgroud)

php facebook facebook-graph-api laravel-5.2

9
推荐指数
1
解决办法
7296
查看次数

Laravel 连接表并连接行

所以我有两个表,组织和联系人。两个表都有“电子邮件”列,我需要做的是保留组织的名称,但在电子邮件列中连接所有电子邮件(组织+所有联系人电子邮件)。

这是我尝试过的一些版本,但没有成功

1)这个不分组:

$customers = DB::table('customers')
    ->whereRaw('LENGTH(customers.email) > 4')
    ->select([
        'customers.id',
        'customers.name',
        'customers.email'
    ]);

$contacts = DB::table('contacts')
    ->whereRaw('LENGTH(contacts.email) > 4')
    ->leftJoin('customers', 'contacts.customer_id', '=', 'customers.id')
    ->select([
        'customers.id',
        'customers.name',
        'contacts.email'
    ]);

return $customers
    ->union($contacts)
    ->select([
        'id',
        'name',
        DB::raw('GROUP_CONCAT(DISTINCT email, ", ") AS emails'),
    ])
    ->groupBy('id')
    ->get();
Run Code Online (Sandbox Code Playgroud)

2)这个实际上非常接近,但它不会过滤掉联系人或客户整体都没有的条目DB::raw('LENGTH(email) > 4')

return $customers = DB::table('customers')
                ->leftJoin('contacts', 'contacts.customer_id', '=', 'customers.id')
                ->select([
                    'customers.id',
                    'customers.name',
                    'registration',
                    DB::raw('GROUP_CONCAT(DISTINCT contacts.email, ", ") AS contact_emails'),
                    'customers.email'
                ])
                ->groupBy('customers.id')
                ->get();
Run Code Online (Sandbox Code Playgroud)

3)我尝试更接近子查询(我知道它只会过滤掉没有电子邮件的联系人)

3.1) 尝试子查询 1 会导致错误:JoinClause::whereRaw()不存在

return $customers = …
Run Code Online (Sandbox Code Playgroud)

mysql laravel laravel-5

4
推荐指数
1
解决办法
4285
查看次数

食尸鬼的form_params不接受数组

我正在使用Guzzle 6,并且无法在客户端主体中传递带有form_params的数组

$postFields = [
    form_params => [
        'data[test]' => "TEST",
        'data[whatever]' => "Whatever..."
    ]
];

$client = new GuzzleClient([
        'cookies' => $jar, // The cookie
        'allow_redirects' => true, // Max 5 Redirects
        'base_uri' => $this->navigateUrl, // Base Uri
        'headers' => $this->headers
]);
$response = $client->post('api',[$postFields]);
Run Code Online (Sandbox Code Playgroud)

最终,当我发送请求时,我的数据不见了……但是,如果我在响应中手动添加数据,它就可以正常工作。

$response = $client->post(
    'api',
    [form_params => [
        'data[test]'=>"TEST",
        'data[wht]' => 'Whatever'
    ],
]
// It's working this way...
Run Code Online (Sandbox Code Playgroud)

如果您需要更多信息,我希望我很清楚。提前致谢。

php guzzle guzzle6

1
推荐指数
1
解决办法
4700
查看次数

Laravel 数据表关系

所以在这个应用程序中Drawing belongsTo Customer。我有数据表

            <table id='drawing-table' class="table table-bordered table-hover">
                <thead>
                    <tr>
                        <th>Drawing number</th>
                        <th>Customer</th>
                    </tr>
                </thead>
            </table>
Run Code Online (Sandbox Code Playgroud)

这表明$darwing->number$customer->title。加载信息 I use yajra\Datatables\Datatables;.

数据是用这个 JS 方法加载的:

$(function () {
    $('#drawing-table').DataTable({
        processing: true,
        serverSide: true,
        ajax: '{{route('drawings.datatable')}}',
        columns: [
            { data: 'number', name: 'number' },
            { data: 'customer.title', name: 'customer' },
        ]
    });
});
Run Code Online (Sandbox Code Playgroud)

这个 Laravel 方法:

public function datatable()
{
    $drawings = Drawing::select(array('drawings.id','drawings.number'));

    return Datatables::of(Drawing::with('customer')->select('*'))->make(true);
}
Run Code Online (Sandbox Code Playgroud)

问题

  1. 如何使用数据表搜索窗口$customer->title
  2. 如何将图纸编号和客户名称显示为链接?

datatable laravel-4.2

0
推荐指数
1
解决办法
1万
查看次数