小编Jos*_*low的帖子

Laravel:将参数传递给函数?

我试图将两个参数传递给whereHas与Laravel的函数,因为其他它不能使用$businessid但它抛出错误,任何人都可以帮忙吗?

错误:

HomeController.php第16行中的FatalThrowableError:类型错误:函数App\Http\Controllers\Business\User\HomeController :: App\Http\Controllers\Business\User {closure}()的参数太少,1传递给C:\第938行的web\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Builder.php,预计正好2


码:

<?php

namespace App\Http\Controllers\Business\User;

use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Auth;
use App\Database\Frontend\Roleplay\Business\Businesses;
use App\Database\Frontend\User\Player;

class HomeController extends Controller
{
    public function getView(Request $request, $businessid)
    {
        $workerCount = Player::whereHas("roleplay", function($q2, $businessid) {
            $q2->where('business_id', $businessid);
        })->count();

        $workersWorkingCount = Player::where('currently_working', '1')->whereHas("roleplay", function($q2, $businessid) {
            $q2->where('business_id', $businessid);
        })->count();

        $workersOnlineCount = Player::where('online', '1')->whereHas("roleplay", function($q2, $businessid) {
            $q2->where('business_id', $businessid);
        })->count();

        $workersOfflineCount = Player::where('online', '0')->whereHas("roleplay", function($q2, $businessid) {
            $q2->where('business_id', $businessid);
        })->count();

        return view('business.home', compact(
            'workerCount',
            'workersWorkingCount',
            'workersOnlineCount', …
Run Code Online (Sandbox Code Playgroud)

php laravel

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

使用C#读取大型XML文件

我想知道如何从桌面读取XML文件并将其放入字符串中?

这是我的XML:

<smallusers>
    <user id="1">
        <name>John</name>
        <motto>I am john, who are you?</motto>
    </user>
    <user id="2">
        <name>Peter</name>
        <motto>Hello everyone!</motto>
    </user>
</smallusers>
<bigusers>
    <user id="3">
        <name>Barry</name>
        <motto>Earth is awesome</motto>
    </user>
</bigusers>
Run Code Online (Sandbox Code Playgroud)

我想存储每个用户,但仍然检测他们的小或大,有没有办法做到这一点?

在你降低这一点之前,你可能想检查谷歌,因为我做了研究,但没有发现任何东西.

c# xml serialization deserialization

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

并发线程在套接字上发送数据的速度较慢?

下面我有一个应用程序,我试图使用C#套接字以尽可能快的方式发送尽可能多的数据.数据启动10秒后,我停止数据发送并等待控制台密钥,同时向控制台写入已发送的请求数.

当将线程数量设置为1时,我达到了更高的请求.这是日志

Attempt 1    => 86873
Attempt 2    => 107324
Attempt 3    => 97426
Attempt 4    => 94720
Attempt 5    => 97927
Attempt 6    => 94327
Attempt 7    => 94791
Run Code Online (Sandbox Code Playgroud)

正如你所看到的那样,它的峰值在80,000到110,000之间.当它设置为高于1的任何值时(我试过1和2)它甚至没有达到80,000,它在10秒内达到约70-75,000.我的想法是更多的线程=更多的数据发送,因为它在幕后做了更多的工作?谁能给我一些关于此的信息?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace RDOS
{
    public class ThreadHandler
    {
        private int count = 0;
        private int threadCount = 3;
        private List<Thread> _threads = new List<Thread>();

        private string _ip;
        private int _port;

        public int RequestsSent;
        public …
Run Code Online (Sandbox Code Playgroud)

c# multithreading

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

标签 统计

c# ×2

deserialization ×1

laravel ×1

multithreading ×1

php ×1

serialization ×1

xml ×1