@azuron So here it goes:
// using eager loading constraints
$user = User::with(['posts' => function ($q) {
$q->wherePivot('checked', 'checked');
}])->find($userId);
// OR using lazy eager loading
$user->load(['posts' => function ($q) {
$q->wherePivot('checked', 'checked');
}]);
// then
$user->posts; // collection of checked posts only
// OR without loading the relation on $user object
$checkedPosts = $user->posts()->wherePivot('checked', 'checked')->get();
Also, I suggest you use bool type for this field instead of checked / notChecked values:
$table->boolean('checked')->default(false);
then you do:
->wherePivot('checked', true/false);
and it returns value that evaluates to either true or false. While now, both values being strings, evaluate to true.