*/ protected $fillable = [ 'lan_id', 'name', 'guardian_name', 'amount_left', 'deposit', 'give_leftover', 'comment', 'customer_group_id', 'is_in_group' ]; /** * Make this customer a member of a group and hand over the balance they have * left to spend. Returns the amount that was moved, for the caller to add to * the group's own row. * * Membership and money move together — a member keeps no balance of their own. */ public function joinGroup(int $groupId): int { $moved = (int) $this->amount_left; $this->customer_group_id = $groupId; $this->is_in_group = 1; $this->deposit = 0; $this->amount_left = 0; $this->save(); return $moved; } /** * Get the purchases for the customer. */ public function purchases() { return $this->hasMany(Purchase::class); } /** * Get the deposit for the customer. */ public function deposits() { return $this->hasMany(Deposit::class); } }