小编u_m*_*der的帖子

Laravel 根据另一个字段的值验证该字段

我想验证两个字段,即“类型”和“选项”,其中“类型”字段是枚举。仅当 'type' 字段的值为 'opt' 时,才应验证 'options' 字段。

$this->validate($request, [
    'type' => 'required|in:opt,number,text,file,image',
    'options'=>the condition I need(if type is 'opt')
]);
Run Code Online (Sandbox Code Playgroud)

php validation laravel

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

如何从symfony表单处理程序中的表单中删除空值字段

我想在两个条件下更新数据:

  1. 当用户输入表单中的所有字段时(姓名,电子邮件,密码)
  2. 当用户没有输入密码时(我只需要更新姓名和电子邮件).

我有以下formHandler方法.

public function process(UserInterface $user)
{
    $this->form->setData($user);

    if ('POST' === $this->request->getMethod()) {                       

        $password = trim($this->request->get('fos_user_profile_form')['password']) ;
        // Checked where password is empty
        // But when I remove the password field, it doesn't update anything.
        if(empty($password))
        {
            $this->form->remove('password');            
        }

        $this->form->bind($this->request);

        if ($this->form->isValid()) {
            $this->onSuccess($user);

            return true;
        }

        // Reloads the user to reset its username. This is needed when the
        // username or password have been changed to avoid issues with the
        // security layer.
        $this->userManager->reloadUser($user); …
Run Code Online (Sandbox Code Playgroud)

symfony-forms symfony

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

在缩放时保持文本大小相同

我想在页面顶部创建一条无法缩放的行.既不是行,也不是包含在其中的文本.主要问题是文本.每当我放大浏览器时,线条保持相同的高度,但其中的文字会增长,并从线条中消失.

有什么css命令我可以使用什么?

我已经尝试过font-size-adjust: none;,-webkit-text-size-adjust: none;但没有一个能奏效.

这是我试图做的小提琴.

html css

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

无法在centOS上安装php-mbstring

我在centOs上有php 5.4,我已经删除了并安装了php 7.现在我在服务器上的一个代码返回以下错误:

PHP致命错误:调用未定义的函数mb_internal_encoding()

当我运行时,yum install php-mbstring我收到以下错误:

错误:php70u-与php-common-5.4.16-43.el7_4.x86_64冲突

错误:php70u-json与php-common-5.4.16-43.el7_4.x86_64冲突

我已经删除并安装了几次php7,但我没有工作.似乎centOs想要安装旧版本的软件包,但我不知道如何告诉它下载最新版本的mbstring

php linux centos

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

参数过多,预​​期参数“命令”“ sql”

编写命令时出现问题:

php bin/console doctrine:query:sql 'SELECT * FROM comment'
Run Code Online (Sandbox Code Playgroud)

输入后,我得到了:

2019-03-24T13:20 + 100:00 [错误]运行命令“ doctrine:query:sql“'SELECT”“ *” FROM“ comment'”“时引发错误。消息:“参数太多,预期参数“命令”“ sql”。

参数太多,期望参数“ command”“ sql”。

那我怎么做错了呢?谢谢

php

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

使用php过滤JSON数据

我试图迭代这个json文件并过滤掉我想要拆分结果的不需要的元素,所以我有一个Customers列表或者供应商列表json文件:

{
  "$descriptor": "Test",
  "$resources": [
    {
      "$uuid": "281d393c-7c32-4640-aca2-c286f6467bb1",
      "$descriptor": "",
      "customerSupplierFlag": "Customer"
    },
    {
      "$uuid": "87a132a9-95d3-47fd-8667-77cca9c78436",
      "$descriptor": "",
      "customerSupplierFlag": "Customer"
    },
    {
      "$uuid": "8a75345c-73c7-4852-865c-f468c93c8306",
      "$descriptor": "",
      "customerSupplierFlag": "Supplier"
    },
    {
      "$uuid": "a2705e38-18d8-4669-a2fb-f18a87cd1cc6",
      "$descriptor": "",
      "customerSupplierFlag": "Supplier"
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

例如

    {
      "$uuid": "281d393c-7c32-4640-aca2-c286f6467bb1",
      "$descriptor": "",
      "customerSupplierFlag": "Customer"
    },
    {
      "$uuid": "87a132a9-95d3-47fd-8667-77cca9c78436",
      "$descriptor": "",
      "customerSupplierFlag": "Customer"
    },
Run Code Online (Sandbox Code Playgroud)

我的PHP代码是

$array = json_decode($result, true);


for ($i = 0; $i < count($array['$resources']); $i++){
    foreach ($array['$resources'][$i]['customerSupplierFlag'][Customer] as $item)
    {
        // do what you want …
Run Code Online (Sandbox Code Playgroud)

php json

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

与使用常规简单 HTML 标签构建视图元素相比,使用 laravelcollective/html 组件有什么优势?

当我们可以使用简单的 html 标签来构建 HTML 元素时,我们真的需要额外的组件吗?

{!! Form::open(['action' => 'Controller@method']) !!}
...
{!! Form::close() !!}
Run Code Online (Sandbox Code Playgroud)

相当于

<form action="{{url('Controller@method')}}">
...
</form>

Form::label('email', 'E-Mail Address', ['class' => 'awesome']);
Run Code Online (Sandbox Code Playgroud)

相当于

<label class='awesome' name='email'> E-Mail Address</label>
Run Code Online (Sandbox Code Playgroud)

ETC...

是否有一些事情是我们无法使用常规 html 标签实现的?如果是这样,可以混合使用吗?(html 标签和 laravelcollective 元素)

html php laravel-5 laravelcollective

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

简单的字符串替换字符

我有一个字符串,如:

"Hello ? My name is ? I am ? years old"
Run Code Online (Sandbox Code Playgroud)

我有一个数组,如:

['George','Jonathan',35]
Run Code Online (Sandbox Code Playgroud)

我想要合并并返回的结果:

`Hello "Geroge" My name is "Jonathan" I am "35" years old`
Run Code Online (Sandbox Code Playgroud)

我如何在php中完成此操作?

我尝试使用,str_ireplace但它说“数组到字符串的转换”

php string

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

图片上的jQuery Zoom插件点击

我在网上进行了大量搜索,但未找到所需的解决方案,我想显示与大图像相同的图像(表示当我单击图像时,它使用缩放选项等显示与大图像相同的图像),请帮我,而解决方案是在HTML,css,js或jquery插件中,我只需要一个解决方案。

html javascript css jquery

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

Laravel 5-调用未定义的方法Illuminate \ Database \ Eloquent \ Collection :: Paginate()

我有一个错误

调用未定义的方法Illuminate \ Database \ Eloquent \ Collection :: Paginate()

我一直在这样做:

public function index ()
{

    $articles = Article::latest('published_at')->published()->get()->paginate(5);
    $articlesLink = $articles->render();

    return view('articles.index', compact('articles', 'articlesLink'));
}
Run Code Online (Sandbox Code Playgroud)

php pagination laravel-5

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