'Where relationship column equals?
I am trying to grab all records where Player's relationship called stats() has a column value of something. I would usually do ::where('column_name' 'column_value') for the players table, but how can I get ::where the relationship table's column equals to something?
Player::where('column_name', 'column_value')->get();
But I want to check a column in the relationships table?
public function roleplay()
{
return $this->hasOne('App\Database\Frontend\User\Roleplay', 'user_id', 'id');
}
Solution 1:[1]
Laravel 8^ : doc Relationship Existence Queries
Product::with('categoreys')->whereRelation('categoreys', 'status', '0')
->get();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ali hassan |
