Попробуйте это. Я знаю, что вопрос несколько старый, но это другой подход к проблеме.
Я также заметил, что проблема возникает чуть выше поля password
.
Я попробовал как методы, подобные
<form autocomplete="off">
и <input autocomplete="off">
, но ни один из них не работал для меня.
Поэтому я исправил его с помощью нижеприведенного фрагмента - просто добавил другое текстовое поле чуть выше типа пароля (f5).
Что-то вроде этого:
<input type="text" name="prevent_autofill" id="prevent_autofill" value="" style="display:none;" />
<input type="password" name="password_fake" id="password_fake" value="" style="display:none;" />
<input type="password" name="password" id="password" value="" />
Надеюсь, что это поможет кому-то.
class Tutorial extends Model
{
function chapters()
{
return $this->hasMany('App\Chapter');
}
function videos()
{
return $this->hasManyThrough('App\Video', 'App\Chapter');
}
}
И тогда вы можете сделать:
Tutorial::withCount(['chapters', 'videos'])
Подсчет связанных моделей Если вы хотите подсчитать количество результатов в связи без фактической загрузки их, вы можете использовать метод withCount, который поместит столбец {отношение} _count на ваших результирующих моделей. Например:
$posts = App\Post::withCount('comments')->get();
foreach ($posts as $post) {
echo $post->comments_count;
}
Вы можете добавить «счетчики» для нескольких отношений, а также добавить ограничения к запросам:
$posts = App\Post::withCount(['votes', 'comments' => function ($query) {
$query->where('content', 'like', 'foo%');
}])->get();
echo $posts[0]->votes_count;
echo $posts[0]->comments_count;
Вы также можете псевдоним результата подсчета отношений, позволяя несколько учитывает одно и то же отношение:
$posts = App\Post::withCount([
'comments',
'comments as pending_comments_count' => function ($query) {
$query->where('approved', false);
}
])->get();
echo $posts[0]->comments_count;
echo $posts[0]->pending_comments_count;
Если вы комбинируете withCount с оператором select, убедитесь, что вы вызываете withCount после метода select:
$posts = App\Post::select(['title', 'body'])->withCount('comments');
echo $posts[0]->title;
echo $posts[0]->body;
echo $posts[0]->comments_count;
Попробуйте
Модель клиента
public function numberOfProjects()
{
return $this->hasMany(Project::class);
}
Контроллер
$customers = Customer::where(['is_active'=>1])
->with(['customerContactInformation'=> function ($query) {
$query->where('is_active',1);
}])
->withCount('numberOfProjects') //you can get count using this
->skip($skip)
->take(10)
->get();
Это должно работа
$customers = Customer::withCount('numberOfProjects')->get();
WithCount
о конкретном статусе
$customers = Customer::withCount([
'numberOfProjects',
'numberOfProjects as approved_count' => function ($query) {
$query->where('approved', true);
}
])
->get();