when($filters['search'] ?? false, function ($query, $search) { return $query ->where('number', 'iLIKE', '%' . $search . '%') ->orWhere('nominal', 'LIKE', '%' . $search . '%'); }); } public function customer() { return $this->belongsTo(Customer::class, 'customer_id', 'id'); } public function event(){ return $this->belongsTo(VoucherEvent::class,"voucher_event_id"); } public function location(){ return $this->belongsTo(Location::class,"location_id"); } public function affiliator(){ return $this->belongsTo(Affiliator::class); } public function referenceIssued(){ return $this->morphTo(); } public function referenceUsed(){ return $this->morphTo(); } public function item() { return $this->belongsTo(ItemReference::class, 'item_reference_id', 'id'); } }