我在尝试根据分数和尝试对文档进行排名时遇到问题
"$rank must be specified with a top level sortBy expression with exactly one element"
Run Code Online (Sandbox Code Playgroud)
查询是:
$resultListing = UserScore::raw(function ($collection){
return $collection->aggregate([
['$setWindowFields' => [
'sortBy' => [ 'score'=>-1, 'attempts'=>1],
'output' => [ 'scoreRank' => ['$rank'=>(object) [] ] ],
]]
]);
});
Run Code Online (Sandbox Code Playgroud)
给出的语法是:
{
$setWindowFields: {
partitionBy: <expression>,
sortBy: {
<sort field 1>: <sort order>,
<sort field 2>: <sort order>,
...,
<sort field n>: <sort order>
},
Run Code Online (Sandbox Code Playgroud)
是否可以根据多个字段对文档进行排名?
我正在使用 Laravel 版本 5.7.20 构建自定义 Markdown 模板。/resources/views/vendor/notifications/email.blade.php
发出命令后生成的模板被复制php artisan vendor:publish --tag=laravel-notifications。
显示 HTML 的以下作品:
return (new MailMessage)
->line(new HtmlString('The <strong>introduction</strong> to the notification.'))
->line('The <strong>introduction</strong> to the notification.')
->line(new HtmlString('Due Date: <strong>' . Carbon::parse($this->info->created_at)->format('Y-m-d H:i') . '</strong>'))
->line('Due Date: <strong>' . Carbon::parse($this->info->created_at)->format('Y-m-d H:i') . '</strong>')
->action('Notification Action', url('/'));
Run Code Online (Sandbox Code Playgroud)

这是行不通的。这是使用我自己的降价
return (new MailMessage)
->line(new HtmlString('The <strong>introduction</strong> to the notification.'))
->line('The <strong>introduction</strong> to the notification.')
->line(new HtmlString('Due Date: <strong>' . Carbon::parse($this->info->created_at)->format('Y-m-d H:i').'</strong>'))
->line('Due Date: <strong>' . Carbon::parse($this->info->created_at)->format('Y-m-d H:i').'</strong>')
->action('Notification …Run Code Online (Sandbox Code Playgroud) 我有一个控制器方法,我想每分钟运行一次。我阅读了任务计划的文档,但它似乎只记录了命令。
有什么方法可以使用它每分钟调用路由/控制器方法/脚本吗?
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Acc;
class ScriptController extends Controller
{
public function updateAcc()
{
$c = new Scripts\AccountA();
$xoo = $c->getInfo();
$z = json_decode($xoo,true);
$data= new Acc();
$data->price = $z["result"];
$data->save();
}
}
Run Code Online (Sandbox Code Playgroud)
我需要使用数据库外观和外部类等......
我在用:
在 Tinker 和 Routing 上,我使用文档中的Str::replace()方法,但出现错误:
带有消息 Method Illuminate\Support\Str::replace 的 BadMethodCallException 不存在。
示例 1:
root@c6dd4af63e3c:/var/www/html# php artisan tinker
Psy Shell v0.10.7 (PHP 7.4.9 — cli) by Justin Hileman
>>> Illuminate\Support\Str::replace('8.x', '9.x', 'Laravel 8.x');
BadMethodCallException with message 'Method Illuminate\Support\Str::replace does not exist.'
>>>
Run Code Online (Sandbox Code Playgroud)
示例2:
Route::get('/test', function () {
return Illuminate\Support\Str::replace('8.x', '9.x', 'Laravel 8.x');
});
Run Code Online (Sandbox Code Playgroud)
为什么会出现此错误以及如何解决?