小编mas*_*oni的帖子

Json擅长使用电源查询

我有一些json网站,我想转换为excel使用该power query选项from web.但我遇到了一个小问题.我json看起来像这样:

[
    {
        "id" : 1,
        "visitors" : 26,
        "some_number" : 1,
        "value" : 3500
    },
    {
        "id" : 2,
        "visitors" : 21,
        "some_number" : 5,
        "value" : 2000
    }
]
Run Code Online (Sandbox Code Playgroud)

但当我使用from web我得到这个:

在此输入图像描述

我可以深入到一个记录,将其转换为一个表,转置并使用第一行作为标题,但后来我只得到一行.我怎样才能将所有数据都放到表中而不只是一行?

excel json powerquery

24
推荐指数
3
解决办法
2万
查看次数

刀片if(isset)不起作用Laravel

嗨,我正在尝试使用刀片版本检查变量是否已设置.但原始的PHP正在工作,刀片版本不是.有帮助吗?

控制器:

public function viewRegistrationForm()
{
    $usersType = UsersType::all();
    return View::make('search')->with('usersType',$usersType);
}
Run Code Online (Sandbox Code Playgroud)

视图:

{{ $usersType or '' }}
Run Code Online (Sandbox Code Playgroud)

它显示错误:

未定义的变量:usersType(查看:C:\ xampp\htdocs\clubhub\app\views\search.blade.php)

php laravel

22
推荐指数
5
解决办法
8万
查看次数

如何在React中执行下一个函数之前完成所有获取?

使用ReactJS,我有两个不同的API点,我试图得到和重组:studentsscores.它们都是一个对象数组.

我的目标是:首先,获得学生和分数,其次,学生和分数保存在州,我将修改它们并根据学生和分数状态创建一个新状态.总之,我有3个功能:getStudents,getScores,和rearrangeStudentsAndScores.getStudents并且getScores需要在完成之前完成rearrangeStudentsAndScores.

我的问题是:有时rearrangeStudentsAndScores会在getScores完成之前运行.那搞砸rearrangeStudentsAndScores了.但有时它会完成.不确定为什么它在50%的时间都有效,但我需要让它在100%的时间内都能正常工作.

这是我fetch students and scores在我的Client文件中所要做的:

function getStudents(cb){
    return fetch(`api/students`, {
        headers: {
            'Content-Type': 'application/json',
            'Accept': 'application/json'
        }
    }).then((response) => response.json())
    .then(cb)
};

function getScores(cb){
    return fetch(`api/scores`, {
        headers: {
            'Content-Type': 'application/json',
            'Accept': 'application/json'
        }
    }).then((response) => response.json())
    .then(cb)
};
Run Code Online (Sandbox Code Playgroud)

然后我把它们组合在一起:

function getStudentsAndScores(cbStudent, cbScores, cbStudentsScores){
    getStudents(cbStudent).then(getScores(cbScores)).then(cbStudentsScores);
}
Run Code Online (Sandbox Code Playgroud)

在我的反应应用程序中,我有以下内容:

getStudentsAndScores(){
    Client.getStudentsAndScores(
        (students) …
Run Code Online (Sandbox Code Playgroud)

javascript asynchronous fetch reactjs

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

使用 Laravel 在 Json 列中搜索

在我的电子邮件表中,我有一列名为Tocolumn-type Json。这是值的存储方式:

[
    {
        "emailAddress": {
            "name": "Test", 
            "address": "test@example.com"
        }
    }, 
    {
        "emailAddress": {
            "name": "Test 2", 
            "address": "test2@example.com"
        }
    }
]
Run Code Online (Sandbox Code Playgroud)

现在我想要发送到“test@example.com”的所有电子邮件的集合。我试过:

DB::table('emails')->whereJsonContains('to->emailAddress->address', 'test@example.com')->get();
Run Code Online (Sandbox Code Playgroud)

(参见https://laravel.com/docs/5.7/queries#json-where-clauses)但我没有得到匹配。有没有更好的方法来使用 Laravel (Eloquent) 进行搜索?

在调试栏中,我可以看到这个查询被“翻译”为:

select * from `emails` where json_contains(`to`->'$."emailAddress"."address"', '\"test@example.com\"'))
Run Code Online (Sandbox Code Playgroud)

php mysql json laravel laravel-5

12
推荐指数
3
解决办法
2万
查看次数

改变ThisBreaksApplicationSecurity 角度2

我正在尝试动态地在 angular2 中的标签中加载 pdf 文档,当我尝试更改 URL 时,会抛出错误

SafeResourceUrlImplchangingThisBreaksApplicationSecurity:“localhost:8002/pdf.pdf”原型:SafeValueImpl构造函数:SafeResourceUrlImpl()getTypeName:()原型:对象

本地主机:8002/pdf.pdf 无法加载资源:net::ERR_UNKNOWN_URL_SCHEME

这是我设置 URL 的方法,当我需要显示组件时会调用此方法

public show(): void {
    this.visible = true;
    this.visibleAnimate = true;
    console.log(this.src)
    this.DocURL = this.sanitizer.bypassSecurityTrustResourceUrl(this.src);
    console.log(this.DocURL);
}


constructor(private sanitizer: DomSanitizer) {
    this.visible = false;
    this.visibleAnimate = false;

    this.DocURL = this.sanitizer.bypassSecurityTrustResourceUrl(window.location.host + "/pdf.pdf");
}
Run Code Online (Sandbox Code Playgroud)

HTML 部分如下

<div style=" height:650;width:870">
    <object width="870" height="650" type="application/pdf" [data]="DocURL" id="doc" #doc>
        <p>Not able to display the document</p>
    </object>
    <div style="display:none">
        <iframe id="fred" #fred style="border:1px solid #666CCC" title="PDF in an i-Frame" …
Run Code Online (Sandbox Code Playgroud)

ngsanitize angular

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

在Identity中获取当前用户的电子邮件

我使用IIdentity接口获取当前useridusername.

所以实现以下方法:

private static IIdentity GetIdentity()
{
    if (HttpContext.Current != null && HttpContext.Current.User != null)
    {
        return HttpContext.Current.User.Identity;
    }

    return ClaimsPrincipal.Current != null ? ClaimsPrincipal.Current.Identity : null;
}
Run Code Online (Sandbox Code Playgroud)

并添加以下代码:_.For<IIdentity>().Use(() => GetIdentity());我的IoC容器[structuremap].

用法

this._identity.GetUserId();
this._identity.GetUserName();
this._identity.IsAuthenticated
Run Code Online (Sandbox Code Playgroud)

现在我想实施GetEmailAdress方法,如何做到这一点?

this._identity.GetEmailAdress();
Run Code Online (Sandbox Code Playgroud)

使用时this._identity.GetUserName();不要获取用户名表格数据库.

c# asp.net-mvc identity

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

在bootstrap模式中显示的选择插件不能正常工作

我的问题是在我的bootstrap模式上使用选择的显示有问题,任何人都知道这是什么问题?

这是截图 在此输入图像描述

****这是我的代码,我使用Codeigniter和Bootstrap框架****

<div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" class="modal hide fade" id="add_form">
    <div class="modal-header"  style="cursor:move">
        <button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
        <h3 id="myModalLabel" title="drag me around">Add Skill <i class="icon-move" style="margin-top:10px;"></i></h3>
    </div>
    <?php echo form_open('skill/add_skill'); ?>
    <div class="modal-body" style="min-height:400px;">
        <div class="form-horizontal">
            <div class="control-group">
                <div class="control">
                    <label for="control-label" class="control-label"></label>
                    <code>Note :</code> All field mark with <code>*</code> are required.
                </div>
            </div><!-- /control-group -->

            <div class="control-group template">
                <label for="input01" class="control-label">Tenant*:</label>
                <div class="controls">
                    <select name="tenant"  data-placeholder="Select Tenant" class="chzn_a span7 ">
                        <option value=""></option>
                        <?php if(isset($tenant_records)) : foreach($tenant_records …
Run Code Online (Sandbox Code Playgroud)

twitter-bootstrap jquery-chosen

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

Laravel:由于未知错误,文件未上传

我正在尝试将文件上传到两个不同的位置。该lcoations是/2x/ADN /3x/。它以 3x 的速度上传文件,但不会以 2x 的速度上传文件并引发此错误:

由于未知错误,文件未上传

这是我在做什么:

$photo = $request->file('photo');

    if (isset($photo)) {
        if ($photo != null || $photo != '') {

            $imageSize = getimagesize($photo);
            $resolution = $imageSize[0] . 'x' . $imageSize[1];

            if ($resolution == '300x300' || $resolution == '450x450') {

                if (!file_exists(base_path('uploads/custom_avatar'))) {
                    mkdir(base_path('uploads/custom_avatar'), 0777, true);
                }

                $resolution = "3x";

                $uploadPath = base_path('uploads/custom_avatar/' . $resolution . '/');

                $otherImageResolution = '2x';
                $otherImagePath = base_path('uploads/custom_avatar/' . $otherImageResolution . '/');
                //echo $otherImagePath;exit;
                // saving image
                $fileName = $child->id …
Run Code Online (Sandbox Code Playgroud)

php upload file laravel-5.3

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

Laravel 5.4结合两个系列

所以我有两个系列,salescosts.

现在我需要将它们合并为一个集合以满足我的foreach条件(我不确定我是否可以在一个集合中使用两个集合foreach)

RAW查询:

//Raw MySQL Queries for Sales
$total_sales = DB::raw('SUM(receipts.total) as totalSales');
$year_receipt_created = DB::raw('YEAR(receipts.created_at) as year');

//Raw MyQSL Queries for Cost of Goods Sold
$total_cost = DB::raw('(SUM(qty * cost)) as totalCost');
$year_sold = DB::raw('YEAR(created_at) as year');
Run Code Online (Sandbox Code Playgroud)

这是我query的两个collections:

$sales = DB::table('receipts')
            ->where('status', 'served')
            ->where('mode', 'restaurant')
            ->select($total_sales, $year_receipt_created)
            ->groupBy('year')
            ->get();

$costs = DB::table('orders')
            ->where('status', 'served')
            ->select($total_cost, $year_sold)
            ->groupBy('year')
            ->get();
Run Code Online (Sandbox Code Playgroud)

我尝试过测试的东西:将集合转换为数组并尝试合并它们但我似乎遇到了问题.

我还原它是因为我不知道这是不是最好的方式.请让我知道最好的方法是什么.

更新:这是这两个查询的输出,希望它有所帮助:

销售

{
    totalSales: …
Run Code Online (Sandbox Code Playgroud)

php mysql laravel

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

如何在 React Native 中播放 vimeo 视频?

我需要在我的本机应用程序中播放 Vimeo 视频。我正在使用 webview 播放视频,视频播放但我在屏幕上看不到任何内容,音频即将到来但屏幕是空白的。下面是我的代码。是我做错了什么还是有其他方式可以玩 Vimeo?任何帮助,将不胜感激。

<AutoHeightWebView
    startInLoadingState
    style={{ width: "100%", height: '100%', borderColor: 'white', borderWidth: 2 }}
    source={{
        uri: 'https://player.vimeo.com/video/299264098?autoplay=1' //'this.state.videoUrl'
    }}
    onError={() => console.log('on error')}
    onLoad={() => console.log('on load')}
    onLoadStart={() => console.log('on load start')}
    onLoadEnd={() => console.log('on load end')}

    bounces={false}
/>
Run Code Online (Sandbox Code Playgroud)

webview vimeo-player react-native react-native-ios

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

本地通知“schedule”和“trigger”方法执行多次

嗨,我是 ionic 新手,我正在使用 (katzer/cordova-plugin-local-notifications),我遇到了问题,我不知道发生了什么。

当我点击一个链接时,我会生成一个新的通知。但是我不知道为什么当我在通知中第二次点击时,“计划”和“触发”里面的警报被执行了两次,当我在通知中第三次点击时,里面的警报"schedule" 和 "trigger" 执行 3 次,依此类推。

这是我的代码,非常简单:

$scope.addNotification = function (){


    var idaudio = Math.round(Math.random() * 10000);
    var date = Date.now();

    cordova.plugins.notification.local.schedule({
        id: idaudio,
        title: 'Remember',
        text: 'New Remember',
        at: date

    });


    cordova.plugins.notification.local.on("schedule", function(notification){
        alert("scheduled: " + notification.id);
    });


    cordova.plugins.notification.local.on('trigger', function (notification){
        alert("trigger" + notification.id)
    });
}
Run Code Online (Sandbox Code Playgroud)

我需要当我单击通知时,只有一个警报会打印相关的通知 ID。

有人可以帮我吗?

提前致谢。

notifications localnotification phonegap-plugins cordova cordova-plugins

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