Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️
PHP attendize-alternativedoor-managementevent-check-inevent-managementevent-registrationevent-ticketingeventbrite-alternativeeventslaravelopen-sourcephpreactself-hostedsell-ticketssell-tickets-onlineticket-sellingticketing-systemtickettailor-alternativetito-alternative
<?php
namespace HiEvents\Validators\Rules;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Http\Request;
class RequiredIf implements ValidationRule
{
public bool $implicit = true;
private Request $request;
private string $field;
private string $message;
public function __construct(Request $request, string $field, string $message)
{
$this->request = $request;
$this->field = $field;
$this->message = $message;
}
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if ($value === null && $this->request->boolean($this->field)) {
$fail($this->message ?? "$attribute is required");
}
}
}