在Laravel控制器中,我有这个重定向:
return redirect()->back();
Run Code Online (Sandbox Code Playgroud)
这让我回到了我的上一页(比如http:// domain/page).但是,我想让页面跳转到一个特定的锚点(比如说#section).所以最终应该打开这个页面:http:// domain/page#section.我怎样才能做到这一点?我尝试将锚附加到重定向,但这不起作用.
我认为这是一个非常常见的情况.我通常会有这样的形式:
<form method="post">
<textarea name="text"></textarea>
<input type="submit" value="Save" />
</form>
Run Code Online (Sandbox Code Playgroud)
然后用PHP我会从表单中捕获数据($ _POST ['text']),我可以在另一个变量中使用它.
现在,我想使用Quill,因此用户可以使用一个很好的富文本编辑器.Quill似乎非常适合这个,文档非常详细.但是,出于某种原因,我无法找到如何将数据"发布"到表单中.有一个单一的样本页面可以满足我的需求,但我无法在我的示例中完全实现这一点,而在快速入门指南中,这个相当基本的(对我而言)主题没有讨论,我找不到这个在文档中也是.
Quill应该像这样使用吗?我在监督什么吗?是否有推荐的方法使这项工作?
这就是我目前拥有的:
<!doctype html>
<html>
<head>
<title>Test</title>
<meta charset="UTF-8" />
<link href="https://cdn.quilljs.com/1.0.0/quill.snow.css" rel="stylesheet">
</head>
<body>
<form method="post">
<!-- Create the toolbar container -->
<div id="toolbar">
<button class="ql-bold">Bold</button>
<button class="ql-italic">Italic</button>
</div>
<form method="post">
<!-- Create the editor container -->
<div id="editor">
<p>Hello World!</p>
</div>
<input type="submit" value="Save" />
</form>
<!-- Include the Quill library -->
<script src="https://cdn.quilljs.com/1.0.0/quill.js"></script>
<!-- Initialize Quill editor …
Run Code Online (Sandbox Code Playgroud) 将文件推送到我们的服务器后,将执行以下 post-receive 挂钩:
#!/bin/sh
export GIT_WORK_TREE=/home/user/www/
git checkout -f
Run Code Online (Sandbox Code Playgroud)
但是,文件在结帐时获得了非常奇怪的600
权限和文件夹700
。这不是我所期望的(在我们的其他服务器上,我们得到644
和755
)。从这个线程我了解到 git 没有设置权限,所以 git 不应该受到责备。我的问题是:什么是?我怎样才能弄清楚这个问题的原因是什么?
我已经通过在结帐时运行额外的脚本来修复权限来暂时解决它,但我有兴趣解决根本原因。
我正在使用 gitolite 来管理存储库,但我怀疑这是原因。但同样,我很高兴知道我可以从哪里开始,因为此时我不确定如何调查。
根据最初的答案,我查看了服务器上的 umask 设置。该git
用户(这是用来上传文件的用户),umask设置为0002。这在下面的练习证实:
git@server:~$ umask
0002
git@server:~$ touch newfile
git@server:~$ ls -la newfile
-rw-rw-r-- 1 git git 0 Aug 5 10:46 newfile
Run Code Online (Sandbox Code Playgroud)
额外细节:
假设我在PHP中有一个非常简单的CRUD系统来管理数据库。说它拥有一个产品清单。使用Doctrine ORM,我想查询数据库并查看/编辑/添加记录。根据入门手册,
创建实体类时,所有字段都应受保护或为私有字段(非公共字段),每个字段都应具有getter和setter方法($ id除外)。mutator的使用使Doctrine可以挂接到以实体#field = foo直接设置值的方式无法操纵实体的调用。
这是提供的示例:
// src/Product.php
class Product
{
/**
* @var int
*/
protected $id;
/**
* @var string
*/
protected $name;
public function getId()
{
return $this->id;
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
}
}
// Recording a new title
$product->setName("My new name");
$db->persist($product);
$db->flush();
// Echoing the title
echo $product->getName();
Run Code Online (Sandbox Code Playgroud)
但是,这似乎过于复杂。假设我没有必要像实体手册中所述去处理实体的调用。我可以使这段代码更短并执行以下操作:
// src/Product.php
class Product …
Run Code Online (Sandbox Code Playgroud) 我有与之前问的完全相同的问题,但最后一个问题是 6 岁,并且存在新的 Doctrine 版本,所以我现在参考最新版本的 Doctrine 提出这个问题。
我有表测试:
测试:
id | name
1 | aaa
2 |
3 | ccc
4 | aaa
5 |
6 | ddd
Run Code Online (Sandbox Code Playgroud)
我想要名称不为空的结果:
aaa
ccc
aaa
ddd
Run Code Online (Sandbox Code Playgroud)
此语法不起作用:
$em->getRepository('Test')->findBy(array('name' => notnull));
Run Code Online (Sandbox Code Playgroud)
是否有类似的东西可以使用 findBy 语法?
php ×4
doctrine-orm ×2
git ×1
gitolite ×1
javascript ×1
laravel ×1
permissions ×1
quill ×1
redirect ×1