public function scopeSearch(Builder $query, ?string $search = null): Builder 	{ 		$search = preg_replace('/\s+/', '%', $search ?? ''); 		$search = $search ? '%' . $search . '%' : null;  		return $search ? $query->where(static function ($query) use ($search): void { 			$query->whereNotNull('buyer_id') 								->whereHas('buyer', static function ($query) use ($search): void { 									$query->where('name', 'like', $search); 								}); 		}) 						->orWhere(static function ($query) use ($search): void { 							$query->whereNull('buyer_id')->where('buyer_details->name', 'like', $search); 						}) 			 : $query; 	}