小编Sap*_*aik的帖子

如何安全地删除Laravel Debugbar

我有一个不是由我开发的Laravel应用程序.每页底部都有一些奇怪的栏,它是某种类型的Laravel调试工具.

在此输入图像描述

我相信它存储在存储/调试器中.有没有一种安全的方法可以检查是否实际上是这样的,如果可以,我可以删除这种类型的工具而不影响应用程序吗?有没有人知道这件事是什么,如果有任何建议如何安全地删除这将是非常感谢

php laravel laravel-5

16
推荐指数
6
解决办法
2万
查看次数

春季靴子| 如何动态更新Truststore?

我目前已经在Spring Boot应用程序中实现了双向TLS,并且正在以编程方式进行操作,如下所示:

@Bean
public ServletWebServerFactory servContainer() {
    TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
    TomcatConnectorCustomizer tomcatConnectorCustomizer = new TomcatConnectorCustomizer() {
        @Override
        public void customize(Connector connector) {
            connector.setPort(8443);
            connector.setScheme("https");
            connector.setSecure(true);
            Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();

            protocol.setSSLEnabled(true);
            protocol.setKeystoreType("PKCS12");
            protocol.setKeystoreFile(keystorePath);
            protocol.setKeystorePass(keystorePass);
            //client must be authenticated (the cert he sends should be in our trust store)
            protocol.setSSLVerifyClient(Boolean.toString(true));
            protocol.setTruststoreFile(truststorePath);
            protocol.setTruststorePass(truststorePass);
            protocol.setKeyAlias("APP");
        }
    };
    tomcat.addConnectorCustomizers(tomcatConnectorCustomizer);
    return tomcat;
}
Run Code Online (Sandbox Code Playgroud)

这工作正常,并且符合预期。但是我有一个需求,我需要在运行时更新信任存储(例如,@getmapping调用端点时)。

具体来说,我需要在不停止/重新启动应用程序的情况下将新证书添加到TrustStore。因此,我将必须以某种方式修改应用程序的内存中信任存储。

我怎样才能做到这一点?

更新:

我试图动态添加一个Bean,它将一个新的Trust Manager添加到SslContext,但这是行不通的。

@GetMapping("/register")
public String Register() throws Exception {
    ConfigurableApplicationContext configContext = (ConfigurableApplicationContext) appContext; …
Run Code Online (Sandbox Code Playgroud)

java ssl spring truststore spring-boot

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

Eloquent将十进制转换为字符串

我的模型中有一个十进制字段用于赚钱,我在尝试向此字段添加一些数字时注意到错误的结果.

经过进一步检查,我发现十进制字段被转换为字符串,就像"1245114.00"在修补控制台中一样.

我检查了表格结构,我可以验证该字段确实存在decimal(11,3).

之前问过这个问题,但没有答案.

为什么会这样?

php decimal laravel eloquent

5
推荐指数
4
解决办法
9178
查看次数

拉拉维尔 | 询问某些操作的密码

我的 Laravel 项目中有一个表单。当用户尝试提交此表单时,我想显示一个对话框,询问他们的密码(以提高安全性)。即我希望登录用户在他/她想要执行一些关键操作并验证该密码时输入他/她的密码。

我可以弄清楚这个的前端部分,但我不知道如何实现相同的控制器逻辑。

从我找到的文档中Auth::check(),它只检查当前用户是否登录。

我该怎么做呢?

php authentication laravel laravel-5.4

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

laravel - 碳 | diffForHumans() 更短的版本?

我试图弄清楚如何缩短diffForHumanslaravel 中 Carbon 库提供的方法的输出。

默认格式diffForHumans是这样的:从文件

  • 将过去的值与现在的默认值进行比较时:

    1. 5 个月前

    2. 1小时前

但我希望输出类似于:

  1. 1 小时
  2. 5 分钟
  3. 5个月
  4. 2年
  5. 现在

我怎样才能做到这一点?

php date laravel php-carbon laravel-5.4

4
推荐指数
2
解决办法
5753
查看次数

从纳秒获得人类可读时间

我正在尝试实现ETA功能 System.nanoTime()

startTime = System.nanoTime()
Long elapsedTime = System.nanoTime() - startTime;
Long allTimeForDownloading = (elapsedTime * allBytes / downloadedBytes);

Long remainingTime = allTimeForDownloading - elapsedTime;
Run Code Online (Sandbox Code Playgroud)

但我无法想象如何获得纳秒的人类可读形式; 例如:1d 1h,36s3m 50s.

我怎样才能做到这一点?

java time android duration datetime-conversion

4
推荐指数
2
解决办法
1947
查看次数

laravel | 雄辩的foreach不起作用

我正在尝试从用户表中检索所有非管理员用户。像这样

$agents = User::where('is_admin','=', 'false')->get();

//didn't work
foreach ($agents as $agent=>$value) 
{
    echo "{$agent}=>{$value}"."<br>";
}

//tried dumping
dd($agents);
Run Code Online (Sandbox Code Playgroud)

但是它没有用,所以我尝试转储该变量以检查它是否有任何结果,到目前为止我只有一个非管理员用户:这是输出

Collection {#219 ?
#items: array:1 [?
    0 => User {#222 ?
      #casts: array:1 [?]
      #fillable: array:6 [?]
      #hidden: array:2 [?]
      #connection: null
      #table: null
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:10 [?]
      #original: array:10 [?]
      #dates: []
      #dateFormat: null
      #appends: []
      #events: []
      #observables: []
      #relations: []
      #touches: []
      +timestamps: true
      #visible: …
Run Code Online (Sandbox Code Playgroud)

php foreach laravel eloquent laravel-5.4

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

如何通过 URL 将变量传递到数据表搜索字段?

我目前正在开发一个laravel 5.4项目,在该项目中我已经使用DataTables jQuery Plugin. 默认情况下,该数据表(#sample_1)包含一个搜索字段,该字段可以正常工作并根据搜索过滤记录。

数据表位于/home/loan我想知道是否有任何方法可以通过将搜索字符串传递到数据表的搜索字段来加载上面的页面以及经过过滤的记录列表。前任:/home/loan?search=bella

在 Chrome 中检查我的数据表 html 代码后,我发现数据表搜索有

<label>Search:
<input type="search" class="form-control input-sm input-small input-inline" placeholder="" aria-controls="sample_1">
</label>
Run Code Online (Sandbox Code Playgroud)

我相信这包含在数据表插件中。我找不到一种方法来为其分配名称/ID,以便我可以尝试这样做,/home/loan?search=bella 我认为如果它有效的话,这将是最简单的方法。但这是 JavaScript

var initTable1 = function () {

    var table = $('#sample_1');

    // begin first table
    table.dataTable({

        // Internationalisation. For more info refer to http://datatables.net/manual/i18n
        "language": {
            "aria": {
                "sortAscending": ": activate to sort column ascending",
                "sortDescending": ": activate to sort column descending"
            },
            "emptyTable": "No data available …
Run Code Online (Sandbox Code Playgroud)

javascript datatable jquery datatables laravel-5.4

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

拉拉维尔 | 如何在 JavaScript 中访问会话数组?

我正在将一个数组从我的控制器传递给一个视图。

这是控制器功能:

$notification = array(
            'message' => 'Welcome Admin!', 
            'alert_type' => 'success',
        );
return redirect('/home')->with('notification', $notification);
Run Code Online (Sandbox Code Playgroud)

在我看来:

<script>
  @if(Session::has('notification'))//this line works as expected

    var type = "{{ Session::get('alert_type', 'info') }}";
   //but the type var gets assigned with default value(info)
    switch(type){
        case 'info':
            toastr.info("{{ Session::get('message') }}");
            break;

        case 'warning':
            toastr.warning("{{ Session::get('message') }}");
            break;

        case 'success':
            toastr.success("{{ Session::get('message') }}");
            break;

        case 'error':
            toastr.error("{{ Session::get('message') }}");
            break;
    }
  @endif
</script>
Run Code Online (Sandbox Code Playgroud)

正如你所看到的,我试图访问数组值的方式显然有问题 var type = "{{ Session::get('alert_type', 'info') }}";

编辑- 1:我试过做

var type …
Run Code Online (Sandbox Code Playgroud)

javascript arrays laravel laravel-blade laravel-5.4

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

PHP Laravel打破foreach循环2次

有三个foreach循环,在最后一个foreach循环中有一个if条件,

foreach ($candidate_data as $cd) {
        $edu_data=DB::table('applicant_edu_info')
        ->where('applicant_id',$cd->ap_id)
        ->get();
            foreach($edu_data as $ed){
                foreach($neededDegree as $nd){
                    if($neededDegree->edu_degree_id==$ed->edu_degree_id){
                        $education_data[$cd->ap_id]=$neededDegree->name;

                    }
                }
            }
    }
Run Code Online (Sandbox Code Playgroud)

我需要的是,如果条件为真,那么我想打破两个循环并继续从第一个foreach循环运行.请帮忙.

php foreach laravel

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