小编N'B*_*yev的帖子

Laravel 7 - 嵌套资源路由中的范围问题

路线:

我有一个这样的嵌套资源路由定义:

Route::resource('posts.comments', 'CommentController');
Run Code Online (Sandbox Code Playgroud)

这会产生以下路线:

+--------+-----------+--------------------------------------+------------------------+------------------------------------------------+------------+
| Domain | Method    | URI                                  | Name                   | Action                                         | Middleware |
+--------+-----------+--------------------------------------+------------------------+------------------------------------------------+------------+
|        | GET|HEAD  | posts/{post}/comments                | posts.comments.index   | App\Http\Controllers\CommentController@index   | web        |
|        | POST      | posts/{post}/comments                | posts.comments.store   | App\Http\Controllers\CommentController@store   | web        |
|        | GET|HEAD  | posts/{post}/comments/create         | posts.comments.create  | App\Http\Controllers\CommentController@create  | web        |
|        | GET|HEAD  | posts/{post}/comments/{comment}      | posts.comments.show    | App\Http\Controllers\CommentController@show    | web        |
|        | PUT|PATCH | posts/{post}/comments/{comment}      | posts.comments.update  | App\Http\Controllers\CommentController@update  | web        | …
Run Code Online (Sandbox Code Playgroud)

php laravel laravel-7

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

Bootstrap 4 - Bootstrap 模式中的弹出框内的复选框无法正常工作

Bootstrap Modal 的 popover 中有两个复选框。小提琴在这里

HTML:

<div class="container-fluid">
    <div class="row">
        <div class="col-12">
            <button type="button" class="btn btn-primary open-modal" data-toggle="modal" data-target="#bs-modal">
            Open Modal
            </button>
            <div class="modal fade" id="bs-modal" tabindex="-1" role="dialog" aria-hidden="true">
                <div class="modal-dialog modal-lg" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title" id="exampleModalLabel">Bootstrap 4 Modal</h5>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                            </button>
                        </div>
                        <div class="modal-body">
                            <button type="button" class="btn btn-secondary btn-sm bs-popover" data-container="body" data-toggle="popover">
                            Show Popover
                            </button>
                            <div id="popover-content">
                                <div class="form-check">
                                    <input class="form-check-input" type="checkbox" value="1"
                                        id="default-checkbox" name="default-checkbox">
                                    <label class="form-check-label" for="default-checkbox">
                                    Default …
Run Code Online (Sandbox Code Playgroud)

checkbox jquery twitter-bootstrap bootstrap-modal bootstrap-4

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

侧边栏菜单在 Laravel+vue+adminlte 中不起作用

我已经在我的 Laravel + vue 项目中使用 npm 安装了 AminLte v3,所有东西都运行良好,但是当我单击标记为的侧导航栏主菜单时

<li class="nav-item has-treeview">
    <a href="#" class="nav-link">
        <i class="nav-icon fas fa-users"></i>
        <p>
            Members
            <i class="fas fa-angle-left right"></i>
            <span class="badge badge-warning right">new:2</span>
        </p>
    </a>
    <ul class="nav nav-treeview">
        <li class="nav-item">
            <router-link :to="{name : 'members'}" class="nav-link">
                <i class="fas fa-user-check nav-icon"></i>
                <p>All</p>
            </router-link>
        </li>
        <li class="nav-item">
            <router-link :to="{name:'membersLatest'}" class="nav-link">
                <i class="fas fa-user-plus nav-icon"></i>
                <span class="badge badge-danger right">2</span>
                <p>Latest</p>
            </router-link>
        </li>
        <li class="nav-item">
            <router-link :to="{name:'membersPending'}" class="nav-link">
                <i class="fas fa-user-clock nav-icon"></i>
                <p>Pending</p>
            </router-link>
        </li>
        <li class="nav-item">
            <router-link :to="{name:'membersSuspended'}" …
Run Code Online (Sandbox Code Playgroud)

javascript css laravel vue.js adminlte

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

在 GitLab CI/CD 中缓存 Node.js 依赖项的便捷方法

我正在使用npm在我的项目中安装 Node.js 依赖项。我想在node_modules全局缓存 Node.js 包 ( ) 以在部署到 Heroku 时加速管道中的作业。GitLab官方文档中的一个示例:

cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
  - .npm/

before_script:
  - npm ci --cache .npm --prefer-offline
Run Code Online (Sandbox Code Playgroud)

这是GitLab 中的另一个示例

cache:
  paths:
    - node_modules/
Run Code Online (Sandbox Code Playgroud)

发现了一些文章(部署Node.js的应用程序与GitLab CI / CD持续集成用的Node.js,Heroku的和GitLab CI / CD第2部分),该使用上述的第二构型。我确实试了一下,我能够使用这些设置成功地将我的应用程序部署到 Heroku。但我不确定缓存机制是否正常工作。

这些配置有什么区别?哪一种是最方便的缓存 Node.js 包的方法?

我当前的gitlab-ci.yml文件设置:

image: node:latest

cache:
  paths:
    - node_modules/

stages:
  - build
  - deploy

build:
  stage: build
  script:
    - npm i
    - npm i -g gulp-cli
    - gulp …
Run Code Online (Sandbox Code Playgroud)

node.js npm gitlab gitlab-ci gitlab-ci-runner

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

寻找最近点 - 优化

下面的SQL查询几乎是项目中最常用的部分。它的工作原理完全符合我的要求,但是它的成本(cost=11835.77..11835.82 rows=21 width=137)太高并且消耗服务器资源。

SELECT
  "companies"."id",
  "companies"."name",
  MIN(
    ST_Distance(
      addresses.location,
      ST_SetSRID(ST_Point(28.9856799, 41.0842721), 4326)
    )
  ) as distance
from
  "companies"
  left join "branches" on "companies"."id" = "branches"."company_id"
  and "branches"."active" = true
  inner join "addresses" on "branches"."id" = "addresses"."addressable_id"
  and "addresses"."addressable_type" = 'App\Domains\Company\Models\Branch'
where
  "available" = true
group by
  "companies"."id"
order by
  "distance" asc
limit
  21 offset 0;
Run Code Online (Sandbox Code Playgroud)

如果我必须简要解释一下;每个公司都有很多分支机构。我将分支的位置保留在addresses表中。我的目标是通过分页列出距离发送点最近的公司。

以下查询的成本(cost=0.57..23.12 rows=21 width=137)非常低,但是拥有多个分支机构的公司会出现重复。但该公司必须列为单一公司。

select
  "companies"."id",
  "companies"."name"
from
  "companies"
  left join "branches" on "branches"."company_id" = "companies"."id"
  left join "addresses" …
Run Code Online (Sandbox Code Playgroud)

sql postgresql location postgis

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

使用Grafana API的自动身份验证

在我的Web应用程序中,我想提供将经过身份验证的用户从仪表板传递到Grafana的功能

用户使用凭据登录我的仪表板后,将在我的应用程序中显示指向Grafana仪表板的链接。当用户单击该链接时,他/她将被重定向到Grafana页面并自动登录,而不会显示Grafana登录页面。我不希望我的用户必须遇到第二个登录屏幕,在该屏幕上他们会迷惑要输入的用户名/密码。

我遵循了从Web应用程序自动登录到grafana自动登录到grafana仪表板使用凭据或令牌从Web应用程序自动登录到grafana 通过令牌url自动登录的方法,但是没有运气。我找不到合适的清洁解决方案。

我正在使用在Ubuntu Server 18.04上安装的Grafana v6.2.5。

我该如何实施?任何帮助,将不胜感激。

服务器详细信息:Ubuntu Server 18.04,Apache 2.4.29

authentication api get grafana grafana-api

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

如何使用 PHP 中的嵌套函数从所选类别中选择子类别?

首先,我发布了另一个关于此的问题,但没有得到答案,所以我需要发布一个新问题。

我有一个按层次列出类别的函数,我用foreach循环创建了另一个函数(在同一个函数上),并将其用于下拉列表,所以不需要创建另一个查询,多次使用我现有的函数。

我想使用相同的查询来列出所选类别下的子类别。

示例:如果category.php?id=100单击,那么我想在登录页面中列出 100 层级下的子类别。

这是我的功能:

$allCategories = array();
$categoryMulti = array(
    'categories' => array(),
    'parent_cats' => array()
);
while ($row = $stmt->fetch()) {
//I created another array to get subcats didnt work
//$categories['categories'][1]
    $categoryMulti['categories'][$row['cat_id']] = $row;
    $categoryMulti['parent_cats'][$row['parent_id']][] = $row['cat_id'];
    $allCategories[] = $row;
}
function listCategoryTree($parent, $category)
{
    $html = "";
    if (isset($category['parent_cats'][$parent])) {
        $html .= "<ul>\n";
        foreach

 ($category['parent_cats'][$parent] as $cat_id) {
                if (!isset($category['parent_cats'][$cat_id])) {
                    $html .= "<li>" . $category['categories'][$cat_id]['cat_name'] . "</li>";
                } else { …
Run Code Online (Sandbox Code Playgroud)

php mysql hierarchical-data

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

为什么不能覆盖语义UI CSS?

我试图覆盖语义UI的CSS样式,但是,即使我为相关的类指定了特定的类名,它也无法正常工作。这是我的代码:

return (
    <div className="ui grid">
        <div className="three column row">
            <div className="four wide column" ></div>
            <div className="text eight wide column"> <h1>Team Selection</h1></div>
            <div className="four wide column"></div>    
        </div>
        <div className= "three column row">
            <div className="four wide column"></div>
            <div className="eight wide column" style={style1}> </div>
            <div className="four wide column"></div>
        </div>
    </div>  
)


Run Code Online (Sandbox Code Playgroud)

CSS文件:

.text {
    display: flex;
    justify-content: center;
}
Run Code Online (Sandbox Code Playgroud)

javascript css flexbox semantic-ui

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

使用 Slim 框架创建 Rest Api 在 index.php 文件中出错

我复制了 slimeframework qiuck 代码并粘贴到 index.php 中,但是当我在 localhost( http://localhost/MyApiFirstTry/public/hello/testMessage ) 中运行时,

它显示一些错误..

像这样

Fatal error: Uncaught Slim\Exception\HttpNotFoundException: Not found. in C:\xampp\htdocs\MyApiFirstTry\vendor\slim\slim\Slim\Middleware\RoutingMiddleware.php:93 Stack trace: #0 
C:\xampp\htdocs\MyApiFirstTry\vendor\slim\slim\Slim\Routing\RouteRunner.php(72): 
Slim\Middleware\RoutingMiddleware->performRouting(Object(Slim\Psr7\Request)) #1 
C:\xampp\htdocs\MyApiFirstTry\vendor\slim\slim\Slim\MiddlewareDispatcher.php(81):
 Slim\Routing\RouteRunner->handle(Object(Slim\Psr7\Request)) #2 
C:\xampp\htdocs\MyApiFirstTry\vendor\slim\slim\Slim\App.php(211): 
Slim\MiddlewareDispatcher->handle(Object(Slim\Psr7\Request)) #3 C:\xampp\htdocs\MyApiFirstTry\vendor\slim\slim\Slim\App.php(195): 
Slim\App->handle(Object(Slim\Psr7\Request)) #4 C:\xampp\htdocs\MyApiFirstTry\public\index.php(17): Slim\App->run() #5 {main} thrown in 
C:\xampp\htdocs\MyApiFirstTry\vendor\slim\slim\Slim\Middleware\RoutingMiddleware.php on line 93


Run Code Online (Sandbox Code Playgroud)

我如何解决错误..

php slim

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