->groupBy('category.name')
@foreach ($groups as $groupName => $filters)
<optgroup label="{{ $groupName }}">
@foreach ($filters as $filter)
<option>{{ $filter->name }}</option>
@endforeach
</optgroup>
@endforeach
with(['products' => function ($query) use ($sortDirection, $tags) {
$query->whereHas('authors' ,function ($q) use ($tags) {
$query->whereIn('user_id', $tags);
})->orderBy('id', $sortDirection);
}])
'secret' => $this->when($request->user()->isAdmin(), function () {
return 'secret-value';
}),
The to method accepts an email address, a user instance, or a collection of users
public function scopeFilter($query)
{
if (...) {
$query->where('id','>',0);
}
...
много условий
...
})->skip(($pg-1)*$max)->take($max)
return $query;
}
$validator = Validator::make($request->all(), [
'email' => 'required|max:255',
'password' => 'required',
]);
if ($validator->fails()) {
return redirect('login')
->withErrors($validator)
->withInput();
}