下面的代码处理 GET 请求并显示登录页面:
const routes = [
{
path: '/',
name: 'root',
component: Login
}
]
Run Code Online (Sandbox Code Playgroud)
我可以在 vuejs 中使用带有 GET 方法的路由器显示数据。现在,我想接受来自外部网站的 POST 请求/方法。是否可以?如果是,我应该如何实现,如果不可能,是否有其他替代解决方案?
使用 wordpress 插件,我可以轻松地将 php 脚本插入 wp-admin 的后端。但是,这一次,我不想使用 plugin。有没有办法做到这一点?我已经在谷歌上搜索过,但没有找到任何答案。大多数这些网站使用插件。
我有一张有4列的桌子。我想根据输入显示行,并且它应该能够根据优先级字段优先显示。
示例:我的表如下所示:
ID title description tags
1 web developer designer front-end
2 designer front-end web developer
3 front-end web developer designer
Run Code Online (Sandbox Code Playgroud)
我的测试用例如下:
$input = 'web developer' // the sequence should be IDs : 1, 3, 2
$input = 'front-end' // output sequence result is : 3, 2, 1
$input = 'designer' // result sequence : 2, 1, 3
Run Code Online (Sandbox Code Playgroud)
现在,我想优先考虑从标题到基于输入的标签的结果。
$blog = DB::('blogs')
->where('title', 'LIKE', '%$title%')
->where('description', 'LIKE', '%$title%')
->where('tags', 'LIKE', '%$title%');
Run Code Online (Sandbox Code Playgroud)
但是上面的代码似乎没有。
下面的代码显示了laravel中登录用户的所有未读通知:
auth()->user()->unreadNotifications
Run Code Online (Sandbox Code Playgroud)
我将代码放入标记并将其绑定为unreads属性,以便我的vue组件可以访问unreads数据.
<notification :userid="{{ auth()->user()->id }}" :unreads="{{ auth()->user()->unreadNotifications }}"></notification>
Run Code Online (Sandbox Code Playgroud)
一切正常.
从vue js,我可以将未读数据限制为我想要的数字结果.
但是,当我在浏览器中查看源代码时,我可以看到所有通知都显示出来,因此延迟了页面加载,因为它上面有很多结果.
现在,我想限制, auth()->user()->unreadNotifications以便我可以控制要显示的结果数量.我检查了谷歌和laravel文档,但我没有找到.有人知道吗?
我从这里成功安装了 voyager admin
在我的客户端页面上,我创建了一个源自 auth 的自定义注册。我可以成功注册用户。
安装 voyager admin 后,我在客户的注册表单上添加了一个新用户。然后,当我尝试访问时,http://localhost:8000/admin出现错误,如图所示。
下面是第 53 行的图像:
下面是 VoyagerUse.php 的完整代码
<?php
namespace TCG\Voyager\Traits;
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
use TCG\Voyager\Facades\Voyager;
use TCG\Voyager\Models\Role;
/**
* @property \Illuminate\Database\Eloquent\Collection roles
*/
trait VoyagerUser
{
public function role()
{
return $this->belongsTo(Voyager::modelClass('Role'));
}
/**
* Check if User has a Role(s) associated.
*
* @param string|array $name The role to check.
*
* @return bool
*/
public function hasRole($name)
{
if (!$this->relationLoaded('role')) {
$this->load('role');
}
return in_array($this->role->name, (is_array($name) ? …Run Code Online (Sandbox Code Playgroud) 我在下面有一个示例评论表:
id | parent_id | post_id
1 0 1
2 0 1
3 1 1
4 2 1
5 1 1
Run Code Online (Sandbox Code Playgroud)
我想要实现的是根据 post_id 获取所有评论(parent_id=0),并同时计算总回复数。执行查询时,它应显示如下结果:
id 1 has 2 replies
id 2 has 1 reply
Run Code Online (Sandbox Code Playgroud)
下面是我的示例查询,它从给定的帖子中获取所有评论,但问题是,我不确定如何在一个查询中同时计数。
Comment::where('parent_id', '=', 0)
->where('post_id', $postId)
->get();
Run Code Online (Sandbox Code Playgroud)
有谁知道如何解决这个问题?