[ 'source' => 'number' ] ]; } public function scopeFilter(Builder $query, array $filters) { $query->when($filters['search'] ?? false, function ($query, $search) { return $query ->where('name', 'iLIKE', '%' . $search . '%') ->orWhere('phone', 'LIKE', '%' . $search . '%'); }); } public function locations() { return $this->belongsTo(Location::class, 'location_id', 'id'); } public function customerGroup() { return $this->belongsTo(CustomerGroup::class, 'customer_group_id', 'id'); } }