1 week ago

laravel custom validator

Posted 1 week ago by t0berius

I'm working on a custom validator:

    //attach the validator if required
        $validationRulesApplied['shipmentOption'] = [
            Rule::exists('shipment_options')->where(function ($query) use ($product, $request) {
                $query->where('product_id', $product->id)->where('id', $request->shipmentOption);


It's producing the following query:

select count(*) as aggregate from `shipment_options` where `id` = 1 and (`product_id` = 1 and `id` = 1)

How to make sure the shipment_options field is not taken from the form element name? It needs to be: id instead of shipment_options.

Please sign in or create an account to participate in this conversation.