Hello,
I have this Livewire component.
class Commissions extends Component
{
public $commissions;
public $users;
public $selected_user_id;
public function mount()
{
$this->getCommissions();
$this->users = User::
where('company_id', auth()->user()->company_id)
->orderBy('name')
->get();
}
public function updatedSelectedUserId()
{
$this->getCommissions();
}
private function getCommissions()
{
$this->commissions = MonthCommission::
with('user')
->where('user_id', $this->selected_user_id)
->whereNotNull('month')
->orderByDesc('month')
->get();
}
public function render()
{
return view('livewire.commissions');
}
}
I can select a user to get only the commissions for a specific user.
Some users don't have any commissions.
To reproduce the error, here are the steps :
-
I select a user who doesn't have any commission
-
I select a user who has commissions
-
I select a user who doesn't have any commission => here is the error
-
I select a user who has commissions => now I get always the error, even if the user has commissions
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'month_commissions_view.id' in 'where clause' (Connection: mariadb, SQL: select * from month_commissions_view where month_commissions_view.id in (0, 0, 0, 0))
So I get the error only for a user who doesn't have any commission, but only if I have retrieved the commissions for a user who has commissions.
Any idea why ?
Thanks for your help.
V