Laravel Scout:有没有一种方法可以只搜索特定的字段?
目前这条线工作正常:
$es = Element::search($q)->get();
Run Code Online (Sandbox Code Playgroud)
但它搜索标题,短描述和描述字段.我需要它只搜索标题字段.
我在我的页面上使用jquery,并没有其他部分的问题.即使$ .post和$ .get也能正常工作.
现在我正在尝试评估图像是否有任何问题并尝试此代码:
$("#bib").error(function(){
//nothing now
});
Run Code Online (Sandbox Code Playgroud)
我想知道为什么我得到这个错误:
Uncaught TypeError: $(...).error is not a function
at app.js:53
(anonymous) @ app.js:53
Run Code Online (Sandbox Code Playgroud)
如你所见,我缩短了代码以隔离问题,但你得到了全部的想法.目前,这些jquery源包含在页面内:
https://code.jquery.com/jquery-3.1.0.min.js https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js
知道为什么会这样吗?
我对两个运行良好的查询结果进行了合并:
$events1 = \App\Event::Where('valid_to','>=',$today)->orderByRaw('valid_to','ASC')->get();
$events2 = \App\Event::Where('valid_to','<',$today)>orderByRaw('valid_to','ASC')->get();
$events = $events1->merge($events2);
Run Code Online (Sandbox Code Playgroud)
现在,我需要对这个新集合进行分页,并根据建议添加以下内容:
$page = 1;
$perPage = 60;
$pagination = new \Illuminate\Pagination\LengthAwarePaginator(
$events->forPage($page, $perPage),
$events->count(),
$perPage,
$page
);
Run Code Online (Sandbox Code Playgroud)
编辑:对于未来的读者,爱国者的答案很棒,而我做到了。
我正在尝试自学 Laravel 命令,以便稍后我使用它来安排它们。这是我的内核文件:
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
'App\Console\Commands\FooCommand',
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
$schedule->command('App\Console\Commands\FooCommand')->hourly();
}
/**
* Register the Closure based commands for the application.
*
* @return void
*/
protected …Run Code Online (Sandbox Code Playgroud) 我已经设法使用此代码获取所有颜色属性:
$color_terms = get_terms(
array(
'taxonmy'=>'pa_color'
));
Run Code Online (Sandbox Code Playgroud)
这适用于商店页面并返回所有颜色,但如何将其限制为特定类别?假设在名为“衬衫”的类别中我只有 2 种颜色,并且我只想显示这 2 种颜色。